Re: Large images/memort problem.

Discussion in 'Java' started by Jon Skeet, Jul 8, 2003.

  1. Jon Skeet

    Jon Skeet Guest

    enclume42 <> wrote:
    > I need to process scientific images within a Java program.
    > I have to have simultaneously 2 images of 4400x8618 pixels
    > (coded in 16-bits greylevels) in memory, to be loaded from
    > an about 80 MB TIFF file. (The process later involves working
    > on the DataBuffer obtained from the Raster of the BufferedImage,
    > which works well with smaller images.)
    >
    > Unfortunately, when I try to load the image, the line
    > image = ImageIO.read(file);
    > of my code yields the following exception:
    > Exception in thread "main" java.lang.OutOfMemoryError
    >
    > This is on a 1 GB RAM, 2 GB swap box.
    >
    > Questions:
    > - Given the data about my images given above, is there a rule
    > which allows the calculation a the memory required to load
    > these images ?


    I think it'll depend on how will ImageIO handles different formats - it
    may well be that it takes 4 bytes per pixel, if it converts everything
    into ARGB.

    > - What about the memory required to extract the DataBuffer
    > and work with it ?
    >
    > - Any idea on how I could decrease the amount of memory needed ?
    > (I could load partial-image DataBuffer, but the bottleneck now
    > is the image loading...)


    Do you definitely need to decrease the amount of memory needed? If the
    problem is that your app is failing, the first thing to do is
    *increase* the amount of memory available to the JVM. By default it's
    only 64Mb. You can increase this using command-line parameters when
    starting the JVM. For instance:

    java -Xmx768M mypackage.MyClass

    would start the JVM with a maximum heap size of 768Mb, which may well
    be somewhat better for you...

    --
    Jon Skeet - <>
    http://www.pobox.com/~skeet/
    If replying to the group, please do not mail me too
     
    Jon Skeet, Jul 8, 2003
    #1
    1. Advertising

  2. Jon Skeet

    enclume42 Guest

    This did it. Thanks a lot.

    > > - Any idea on how I could decrease the amount of memory needed ?
    > > (I could load partial-image DataBuffer, but the bottleneck now
    > > is the image loading...)

    >
    > Do you definitely need to decrease the amount of memory needed? If the
    > problem is that your app is failing, the first thing to do is
    > *increase* the amount of memory available to the JVM. By default it's
    > only 64Mb. You can increase this using command-line parameters when
    > starting the JVM. For instance:
    >
    > java -Xmx768M mypackage.MyClass
    >
    > would start the JVM with a maximum heap size of 768Mb, which may well
    > be somewhat better for you...
     
    enclume42, Jul 9, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    4
    Views:
    772
    S. Justin Gengo
    Jun 29, 2004
  2. William Rose
    Replies:
    2
    Views:
    390
    Babu Kalakrishnan
    Aug 18, 2004
  3. Cloud Burst
    Replies:
    8
    Views:
    615
    Gary Mc
    Jan 14, 2004
  4. Ketchup
    Replies:
    1
    Views:
    253
    Jan Tielens
    May 25, 2004
  5. Replies:
    5
    Views:
    884
    Xho Jingleheimerschmidt
    Apr 2, 2009
Loading...

Share This Page