Results 1 to 5 of 5
- 10-16-2010, 08:57 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
Image Problem overflowing Heap Space
Hello,
Im having this problem I cant quite figure out what is causing it. Im trying to load an image into Image class by something like ImageIO.Read(New File bla bla bla);
the image is 5MB but fairly large size wise (it is about 5 times the size of my screen) I can load the image fine and diplay the image how I wish, The problem lies however in the fact that it will overflow the java heap space if i leave it on default (64 mb or so?) and will give me that error so long as I dont increase the heap space to at least around 500 or 600 mb.. -Xmx550m
It seems ridiculous that a 5mb image would cause five HUNDRED mb of space to fill. I made sure im not creating it in a loop so its only being created once I cant figure out why else it would cause so much memory usage... Can anybody assist me with this??
- 10-16-2010, 09:09 AM #2
You're confusing the file size with the image size in memory. What's the pixel size of your image. Note that statements like
are meaningless and have no place in a technical discussion.it is about 5 times the size of my screen
Also, what's the bit depth of each pixel? Check the TYPE of the BufferedImage returned by ImageIO#read(...) to know this. In general, images with transparency can occupy more memory than those without, and types supported by an IndexColorModel are less memory intensive than RGB images.
If the memory requirement based on pizel size X bit depth still doesn't tally with what might be expected, post a SSCCE* and provide a test image for download from a file sharing website (Note: not an image sharing site, they typically scale and compress any large image).
* SSCCE : Java Glossary
db
- 10-16-2010, 09:18 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
ok dawg its not meaningless.. its just vague its 5000 x 5000 pixels and 24 bit depth
so you are saying its 5000 x 5000 x 24 bits of memory ??
if i call get type on the buffered image it is type_3byte_bgrLast edited by The Bear Jew; 10-16-2010 at 09:33 AM.
- 10-16-2010, 12:59 PM #4
Don't call me dawg, and find someone else to help with your problems.
db
- 10-16-2010, 06:58 PM #5
5000 x 5000 x 3 = 75,000,000 bytes = ~71.5 mb
Seems pretty straight forward to me:
Keep in mind that the 5 mb file is compressed; It would be prohibitively slow to keep it compressed while using it in your program.
Using a graphics editor (such as GIMP) i would scale the image down (1000x1000?)
1000 x 1000 x 3 = 3,000,000 bytesMy Hobby Project: LegacyClone
Similar Threads
-
large number of DB writes: java heap space problem in using transaction-commit
By narimani in forum JDBCReplies: 0Last Post: 06-28-2010, 12:30 PM -
increasing jvm heap space
By kizyle502 in forum Advanced JavaReplies: 1Last Post: 05-15-2010, 10:51 AM -
no heap space... need more heap
By anupam.kumar in forum Advanced JavaReplies: 3Last Post: 02-08-2010, 04:42 PM -
Heap Space Problem
By segolas in forum Advanced JavaReplies: 6Last Post: 01-14-2010, 11:29 AM -
Problem with Java Heap Space using Socket
By mvillara in forum NetworkingReplies: 3Last Post: 08-21-2009, 04:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks