Re: Memory leak
Posted by
Wayne Rasband on
Jan 31, 2007; 5:50pm
URL: http://imagej.273.s1.nabble.com/Memory-leak-tp3700430p3700433.html
ImageJ 1.38i fixes a bug in the Image>Color>RGB Split command that
could cause it to leak memory. It also opens RGB images using half as
much memory if you are using Java 1.6.
-wayne
On Jan 29, 2007, at 5:22 PM, Gib Bogle wrote:
> Wayne Rasband wrote:
>
>>> I have written a plugin that causes a memory leak. Each time I run
>>> the plugin on a single image (3600 kB TIF) the memory monitor shows
>>> about 14 MB of memory is not released.
>>>
>>> The plugin does a variety of operations:
>>> Polynomial Fit (by Bob Dougherty)
>>> Image Calculator
>>> Multiply
>>> Bandpass Filter
>>> Threshold
>>> Analyze Particles
>>>
>>> At this stage I can't tell where the memory is being retained. I'm
>>> wondering if there is a general rule for ImageJ plugin development
>>> to avoid this problem. If I was just looking at single images it
>>> wouldn't be a concern, but I want to process sets of images (e.g.
>>> 100s) and I can run out of available memory.
>>
>>
>> You can monitor memory usage by starting the Memory Monitor
>> (Plugins>Utilities>Monitor Memory) and then running the plugin. While
>> it is running, periodically click in the ImageJ status bar to force
>> the Java garbage collector to run. Try adding two or three second
>> delays [IJ.wait(2000)] between operations to help determine which one
>> is retaining the memory.
>>
>> -wayne
>
> I think I've located the (or one) source of the memory leak, and
> surprisingly it doesn't seem to be related to any of the plugins.
> When I open an 4.7 MB RGB tif file the memory usage goes up to about
> 10.5 MB. I do Image > Color > RGB Split and the memory used is 18 MB.
> When I close the three image windows the memory used drops to 10.5
> MB. Is this an ImageJ problem, or is there a way for me to force this
> memory to be freed?
>
> Thanks
> Gib
>