Login  Register

Re: memory usage buildup

Posted by Michael Doube on Jan 03, 2011; 10:52am
URL: http://imagej.273.s1.nabble.com/memory-usage-buildup-tp3686005p3686006.html

Hi Jaap,

> I have a plugin that processes a large number of 10MP image files. It
> does a particle analysis, draws some additional things in the output
> image, saves it, does some more processing, saves some data, enfin: a
> lot.
> It runs alright, but when I monitor the amount of memory that imagej
> occupies, I see it increasing rapidly. I have 8GB of internal memory
> (on a 64 bit Windows 7 machine) which is completely occupied after
> processing about 90 images.
>
> Could it be a problem of garbage collection? Is there any way to force
> ImageJ to do that? I should also note that the plugin is written in
> Jython. It is executed from within a wrapper plugin that instantiates
> a JythonInterpreter object.

It sounds like a memory leak.  In my experience the garbage collector
has not been to blame in this situation, instead bad programming can
leave objects in a state in which they are unable to be garbage collected.

The Sun JDK comes with VisualVM with which you can run a set of profiles
on ImageJ (and the offending plugin); from these you can hopefully find
the leak.  I found this guide very helpful:
http://rejeev.blogspot.com/2009/04/analyzing-memory-leak-in-java.html

Michael