Login  Register

Re: Memory consumption

Posted by Mark R. Besonen on Feb 07, 2006; 1:02pm
URL: http://imagej.273.s1.nabble.com/Memory-consumption-tp3703743p3703744.html

At 10:24 PM 2/6/2006, you wrote:

>Hi!
>
>I am a new ImageJ user running into memory problems performing batch
>image processing. I am going to analyze about 75 000 pictures with
>an image segmentation algorithm using the macro script language. The
>macro contains: reading the pictures from a source folder (one at a
>time), adjusting brightness and contrast, performing a background
>subtraction, OTSU thresholding and the particle analysis command.
>The generated outline picture as well as the contents of the summary
>and results text Windows are subsequently saved into separate
>destination folders, and everything is closed again.
>
>And here comes the problem: watching the memory monitor shows me an
>increasing filling of the memory heap (memory is set to 1 GByte). I
>included several Garbage Collection commands using the
>GarbageCollect Plugin (found here on the Listserv - many thanks for
>that), however the memory is not emptied. I cannot see any traces of
>open windows or something similar that could explain the memory
>consumption. It would be really great if someone would have an idea
>to get around the annoying re-starting of the script about every 1200 pictures.
>
>Thank you very much for your help in advance,
>Best,
>Mathias


Hello Mathias,

         Often a single call to the GarbageCollect plugin does not
free up all the memory--sometimes you have to call it 2 or 3 times in
a row.  My solution is to make a simple loop, and run the command 5 times.

         If you are seeing the memory growing progressively via the
Memory Monitor, perhaps you are calling the GarbageCollect plugin
from a location within your script that is not so effective.  If you
send your script, perhaps the many eyes here could make some
suggestions to help.

         When I build a complicated script with multiple loops, it's
easy for my brain to lose track of exactly what is happening.  So as
I am debugging it I use lots of print statements to the ImageJ log
that help me track the flow of the macro.  To make sure the
GarbageCollect plugin is being called effectively, perhaps you could
add a print statement before or after it, or even within the
GarbageCollect loop itself.  Yes, it might fill up the log window
quickly, but it might also provide you with some information about
how effective your call to the GarbageCollect plugin is.

Mark Besonen
UMass Geosciences