Hey, I successfully load a extremely large jpeg file, say 3000 x 2000, into BufferedImage. When I try to load, same size, second jpeg file, out of memory message is shown. Does anyone of you know how to release this BufferedImage so that I can load the second jpg file? Or any other way to load the second jpg file?
Since you are dealing with such large images it may help to make the initial memory pool larger by passing the argument -Xms to the virtual machine:
-Xmsn = Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 2MB. Examples: -Xms6291456 -Xms6144k -Xms6m
from the SDK tool documentation. Keep in mind that this will not cure a memory leak, just hide it for a while. You can use Runtime.freeMemory() and Runtime.totalMemory() to monitor memory usage.