Re: Memory leak
Posted by
Gib Bogle on
Jan 30, 2007; 9:07pm
URL: http://imagej.273.s1.nabble.com/Memory-leak-tp3700430p3700439.html
Albert Cardona wrote:
> Hi Gib,
>
> I have found only three instances in all my ImageJ-related java
> programming where memory leaks occurred:
>
> - you create an ij.ImagePlus on which getImage() has been called, and
> flush() is never called. Note that if you go through the standard
> ImagePlus.show() to create an ImageWindow, on closing that ImageWindow
> will call flush() and then there's no leak.
>
> - you create a java.awt.Image of any sort, and then never call flush()
> on it.
>
> - you register a listener somewhere that holds onto any of the above
> image types, direclty or indirectly through a pointer to your plugin,
> and you don't remove the listener when your plugin exits.
>
> - you are using static fields that hold directly or indirectly images,
> and manage not to get garbage collected (for instance, by calling
> IJ.register() to prevent so, or by closed loop pointer references).
Thanks Albert, but I've tracked the problem to one of ImageJ's functions, Image>Color>RGB Split, so it isn't related to my plugin code.
I have ImageJ version 1.37v, Java version 1.5.0_11, Windows 2000 Service Pack 4. Every time I open a 4.7 MB tif file, do RGB Split, then close the 3 images, the memory usage increases by about 10 MB, and this memory is never freed.
I'd be grateful if someone else using Windows 2000 could check this on their system. I need to perform this operation many times and I run out of memory before I'm finished.