mecnet / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

java.lang.OutOfMemoryError: Java heap space after adding thumbnailator-feature-oom-workaround-SNAPSHOT.jar file #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
per day we will be converting approximately 10,000 images to thumbnail images
File oldFile = new File(decryptedDataSavePath + "//" + fileName+ ".jpg");
File thFile = new File(decryptedDataSavePath + "//th-"+ fileName + ".jpg");
Thumbnails.of(oldFile).size(150, 150).toFile(thFile);

JAVA Version:1.7.0_45
OS:Windows server 2008 64 bit
Memory:7 GB

I added  the  thumbnailator-feature-oom-workaround-SNAPSHOT.jar and
set JAVA_OPTS=%JAVA_OPTS% -Dthumbnailator.conserveMemoryWorkaround=true 
environment variable also.But still I am getting the OOM error

the original image size is 800 * 660
the required image size is 150 * 124

Please suggest me If am doing anything wrong

Original issue reported on code.google.com by saritha....@gmail.com on 2 Jul 2014 at 11:17

GoogleCodeExporter commented 9 years ago
Thank you for filing this issue.

Could you post the stack trace that is shown when the `OutOfMemoryError` occurs?
(Go ahead and obfuscate portions that you don't want to show, as long as the 
relevant Thumbnailator stack trace is present.)

I'm not certain how the `JAVA_OPTS` environmental variable works in Windows, as 
I'm not using one at the moment, as long as the contents of `JAVA_OPTS` is 
actually given to the JVM when the `java` command is invoked, then it should be 
correct.

(However, under the conditions you mention, the code to prevent 
`OutOfMemoryError`s which is enabled by the above option is probably not 
invoked, so there may need to be some investigative work to be done to find the 
cause.)

Original comment by coobird...@gmail.com on 4 Jul 2014 at 6:16

GoogleCodeExporter commented 9 years ago
Hi..
please find the stack trace..and suggest me where I went wrong.
java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:76)
    at java.awt.image.Raster.createInterleavedRaster(Raster.java:271)
    at java.awt.image.BufferedImage.<init>(BufferedImage.java:382)
    at net.coobird.thumbnailator.resizers.ProgressiveBilinearResizer.resize(Unknown Source)
    at net.coobird.thumbnailator.resizers.Resizers.resize(Unknown Source)
    at net.coobird.thumbnailator.makers.ThumbnailMaker.makeThumbnail(Unknown Source)
    at net.coobird.thumbnailator.makers.FixedSizeThumbnailMaker.make(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
    at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)
    at com.wp.util.SecurityUtil.decryptImage(SecurityUtil.java:95)
    at com.wp.android.UploadEncryptedImage.doPost(UploadEncryptedImage.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.wp.filter.MyFilter.doFilter(MyFilter.java:190)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1721)

Jul 03, 2014 12:02:12 PM org.apache.tomcat.util.net.NioEndpoint$SocketProcessor 
doRun
SEVERE: 
java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:92)
    at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:415)
    at java.awt.image.Raster.createWritableRaster(Raster.java:944)
    at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1073)
    at javax.imageio.ImageReader.getDestination(ImageReader.java:2896)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:998)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:966)
    at javax.imageio.ImageReader.read(ImageReader.java:940)
    at net.coobird.thumbnailator.tasks.io.FileImageSource.read(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
    at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)
    at com.wp.util.SecurityUtil.decryptImage(SecurityUtil.java:95)
    at com.wp.android.UploadEncryptedImage.doPost(UploadEncryptedImage.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.wp.filter.MyFilter.doFilter(MyFilter.java:190)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

Original comment by saritha....@gmail.com on 7 Jul 2014 at 5:17

GoogleCodeExporter commented 9 years ago
Sorry for the delayed reply.
Are there any updates to this issue?

I have looked at the above exception, and it appears there are two different 
timings at which the `OutOfMemoryError`s are occuring:

  1. When the resizing operation is creating a new temporary image for making the thumbnail (`ProgressiveBilinearResizer.resize`)
  2. When loading the input image. (`FileImageSource.read`)

Furthermore, you've mentioned that the source image is small ("800 * 660"), 
it's hard to believe that the Thumbnailator code will encounter an 
`OutOfMemoryError` by processing a image that small, unless the JVM is given a 
very small heap space to start with.

This leads me to believe that there might be some other part of your 
application which may be holding on to data that is left on the JVM heap 
memory, causing the call to Thumbnailator to encounter an heap space full 
situation.

Probably what's actually needed is to perform a memory profiling with an tool 
like JVisualVM to analyze what may be on the memory which is causing the 
`OutOfMemoryError`.

Just a question out of curiosity -- is this error reproducible? If so, is there 
a particular image where the OOM situation occurs?

Original comment by coobird...@gmail.com on 17 Aug 2014 at 5:51

GoogleCodeExporter commented 9 years ago
The error was occurring because of heap space.now its got fixed.

Regares,
Saritha

Original comment by saritha....@gmail.com on 17 Aug 2014 at 1:00

GoogleCodeExporter commented 9 years ago
Thank you for the update on this issue.

I'll be closing this issue, as it turned out not to be an issue with 
Thumbnailator itself.

Original comment by coobird...@gmail.com on 17 Aug 2014 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 17 Aug 2014 at 5:53