Posted by
Mark R. Besonen on
URL: http://imagej.273.s1.nabble.com/Memory-matters-I-think-tp3701987p3701988.html
Hello Andy,
Yes, there is a way to flush memory within a macro (to
manually force the JVM to do "garbage collection"). The JVM is
supposed to do garbage collection automatically when necessary, but
as you have found it, it doesn't always do it. So you can manually
do an operation or process successfully, but then run into memory
errors when you automate it via macro functions.
It is very easy to force garbage collection via a plugin,
and perhaps with the newish "call" macro function, but I am pretty
much macro-limited. So last year when I ran into this problem, I
prepared a small tool to help us macro-limited folks. You can find
more details in the mailing list archives, specifically topic 139 in
the archives from June 2005 (see
https://list.nih.gov/cgi-bin/wa?A1=ind0506&L=imagej#139).
Curiously, you don't report that ImageJ actually gives you
an "out of memory" error which is what I see. But maybe things have
changed with newer IJ versions.
Mark Besonen
UMass Geosciences
At 12:22 PM 7/27/2006, you wrote:
>Dear all,
>
>Is there any way to 'flush out' the memory at the start of a macro/for
>loop?
>
>My macros keep coming up with problems that do not occur if I run things
>manually in exactly the same routine!?
>
>For example, on some occasions, it says that run("Create Selection")
>needs a thresholded/binary image. I have set this up correctly:
>
> setAutoThreshold();
> run("Analyze Particles...", "size=5000-Infinity circularity=0.00-1.00
>show=Masks exclude clear include");
> mask = getImageID;
> run("Copy");
> setPasteMode("AND");
> selectImage(img1);
> run("Paste");
> resetThreshold();
> selectImage(mask);
> run("Create Selection"); // requires 1.37j
>
>on other occasions, with the same dataset, it gets passed this point!?
>
>There's also a convex hull problem. Initially, I found that to run:
>
> run("Enlarge...", "enlarge=0");
> run("Fit Spline");
>
>prior to:
>
> run("Convex Hull");
>
>seems to solve the closed/polyline/polygon ROI problem. This, however,
>is sometimes reoccurring?!
>
>Strange?! My only thought is that it is a memory problem...
>
>Cheers, Andy