Re: Memory leak
Posted by Albert Cardona on Jan 30, 2007; 7:50pm
URL: http://imagej.273.s1.nabble.com/Memory-leak-tp3700430p3700438.html
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).
Hope it helps.
Albert