aspose file tools
The moose likes Performance and the fly likes out of memoey!!  how to release a BufferedImage Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "out of memoey!!  how to release a BufferedImage" Watch "out of memoey!!  how to release a BufferedImage" New topic
Author

out of memoey!! how to release a BufferedImage

chien-rong chen
Greenhorn

Joined: Apr 08, 2004
Posts: 3
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?

Thanks,

chienrong chen
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

invoke flush() on your BufferedImage instance.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
chien-rong chen
Greenhorn

Joined: Apr 08, 2004
Posts: 3
Thank you very much for replying.

I tried this way, but it doesn't work.

Can you explain more clearly? For example, where or when to put this method?

chienrong chen
Sudarshan Muramreddy
Greenhorn

Joined: Jun 08, 2004
Posts: 16
If you are using the same buffer then you need to flush it out, just before you read the next one.

Regards,
Sudarshan
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

There isn't much to explain.

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: out of memoey!! how to release a BufferedImage
 
Similar Threads
Error in Dowlnoading
A question regarding saving jpgs into text files.
pls help ....writing image to file
Image Compression
Casting problem. Image to BufferedImage