Closed textworld closed 2 years ago
And My vm options
-Xmn250m
-Xms500m
-Xmx500m
As you mentioned, you'll need to adjust your JVM heap size.
Thumbnailator needs to load the original image, which will require (roughly speaking) at least double of width * height * 4 bytes
of heap space. For example a 20 megapixel image requires 160 MB of heap. This can be evidenced from the stack trace, which indicates that the OOM is occurring while reading the image:
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1082)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1050)
Since the image you linked is a 15000 x 15000 image, this will require roughtly 900 MB of heap space just to load the image, and another 900 MB to resize the image for a total of 1800 MB of heap.
What you'll need to do is to adjust your JVM heap memory based on the expected image sizes that your application will be handling.
There is a temporary workaround (not guaranteed to always work) to reduce the necessary memory which can be enabled by adding the -Dthumbnailator.conserveMemoryWorkaround=true
JVM option, but it can lead to reduction in the final thumbnail quality. More information can be found here.
Closing for no activity.
Expected behavior
The error will not happen
Actual behavior
Got an OOM error.
Steps to reproduce the behavior
When I resize this image (https://1drv.ms/u/s!AlpawZKZPCw41DIr9maBJADZEfgS?e=e7TPce), the OOM error will happen. This image is a jpg file without the extension name.
And I got this
Environment
Please provide vendor and version information for the Operating System, JDK, and Thumbnailator. Please feel free to add any other information which may be pertinent.
OS vendor and version:
JDK vendor and version:
Thumbnailator version: