Login  Register

Re: Problem closing images

Posted by Nathaniel Ryckman on Jun 28, 2011; 5:36pm
URL: http://imagej.273.s1.nabble.com/Problem-closing-images-tp3683887p3683890.html

at ij.io.Opener.openJpegOrGif(Opener.java:522)

Yeah, actually, the problem is the RAM. As you can see from the error message above, the error <Out of memory> happens when the program tries to open a Jpeg image.

I would normally tell you to look at the online tutorial for increasing memory, but it sounds like you are opening a lot more then 2-4GB of images.

You can't store an entire hard drive worth of images in RAM -- there just isn't enough room. The work around is to only store the images that you are currently working on in RAM while temporarily saving the images that you aren't working on onto the hard drive.

Here's a tool to help you with storing the images in "virtual memory" (aka your hard drive):
http://rsbweb.nih.gov/ij/plugins/virtual-opener.html

strahli wrote
Here is the stack trace:

>>>>>>>>>>>>>>>>>>>>>>>>>>>
<Out of memory>
<All available memory (247MB) has been>
<used. Instructions for making more>
<available can be found in the "Memory" >
<sections of the installation notes at>
<http://imagej.nih.gov/ij/docs/install/>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
load new Picture at Tue Jun 28 09:55:58 CEST 2011, number: 256
<Out of memory>
load new Picture at Tue Jun 28 09:55:59 CEST 2011, number: 257
Exception in thread "Run$_AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
        at ij.process.ColorProcessor.<init>(ColorProcessor.java:31)
        at ij.ImagePlus.setupProcessor(ImagePlus.java:644)
        at ij.ImagePlus.isInvertedLut(ImagePlus.java:1039)
        at ij.measure.Calibration.<init>(Calibration.java:83)
        at ij.ImagePlus.getLocalCalibration(ImagePlus.java:1763)
        at ij.ImagePlus.setType(ImagePlus.java:996)
        at ij.ImagePlus.setImage(ImagePlus.java:473)
        at ij.ImagePlus.<init>(ImagePlus.java:106)
        at ij.io.Opener.openJpegOrGif(Opener.java:522)
        at ij.io.Opener.openImage(Opener.java:268)
        at ij.io.Opener.openImage(Opener.java:303)
        at ij.ImagePlus.<init>(ImagePlus.java:125)
        at AutomaticMode.getNewSnapshot(AutomaticMode.java:85 --   ImagePlus snapshot = new ImagePlus("..");)
        at AutomaticMode.access$0(AutomaticMode.java:83 -- loadNewPicture())
        at AutomaticMode$1.actionPerformed(AutomaticMode.java:75 -- loadNewPicture()-call in startTimer())
        at AutomaticMode.startTimer(AutomaticMode.java:63 -- if(timerEvent))
        at AppGui$1.actionPerformed(AppGui.java:329 -- startTimer())
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

================================
and on the otherhands side I tried to remove many parts and check if they are the problem, but I don't think I found it. The things is I've worked with a Timer but yesterday I was told that I should better move the timing loop to its own thread .. so I tried this but still I get the exception.

A difference I can see between 2 computers, one with WinXP and 2GB RAM and my own with Win7 and 4GB RAM. With the first one I can run about 250 pictures with the second 750 before I get the exception. I hope that this is not a problem with the "low" RAM size of this computer. At least I think a program should be able to work with "only" 2GB.