Results 1 to 5 of 5
  1. #1
    The Bear Jew is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default 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??

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    You're confusing the file size with the image size in memory. What's the pixel size of your image. Note that statements like
    it is about 5 times the size of my screen
    are meaningless and have no place in a technical discussion.

    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

  3. #3
    The Bear Jew is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default

    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_bgr
    Last edited by The Bear Jew; 10-16-2010 at 09:33 AM.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    Don't call me dawg, and find someone else to help with your problems.

    db

  5. #5
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    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 bytes
    My Hobby Project: LegacyClone

Similar Threads

  1. Replies: 0
    Last Post: 06-28-2010, 12:30 PM
  2. increasing jvm heap space
    By kizyle502 in forum Advanced Java
    Replies: 1
    Last Post: 05-15-2010, 10:51 AM
  3. no heap space... need more heap
    By anupam.kumar in forum Advanced Java
    Replies: 3
    Last Post: 02-08-2010, 04:42 PM
  4. Heap Space Problem
    By segolas in forum Advanced Java
    Replies: 6
    Last Post: 01-14-2010, 11:29 AM
  5. Problem with Java Heap Space using Socket
    By mvillara in forum Networking
    Replies: 3
    Last Post: 08-21-2009, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •