Re: Memory leak
Posted by
Gib Bogle on
Jan 30, 2007; 6:55am
URL: http://imagej.273.s1.nabble.com/Memory-leak-tp3700430p3700437.html
Hi Wayne,
I'm not at my work machine at the moment, but it is a Windows 2000
box. I installed the latest ImageJ version a couple of weeks ago, and
today I installed the latest revision of Java 1.5 (something like
1.5.11). The memory is definitely taken - waiting and clicking the
status bar many times has no effect.
Gib
Quoting Rasband Wayne <
[hidden email]>:
> I don't see this problem on my Mac running ImageJ 1.38h and Java 1.6.
> When I open a 4.7MB RGB image memory usage goes to 10MB. Memory usage
> drop to 5.5MB when I use the Image>Color>RGB Split command. It drops to
> less than 1MB when I close the three images. I monitor memory usage by
> clicking in the status bar. Sometimes it takes several clicks to
> reclaim all the memory.
>
> With ImageJ 1.38i, due by the end of the week, the 4.7MB image uses
> 5.5MB when opened and memory usage drops to 4.3MB after using the RGB
> Split command. ImageJ 1.38i opens RGB images using half the memory
> required by earlier versions of ImageJ because the AWT Image needed to
> display the image shares the pixel array with the ColorProcessor.
> ImageJ 1.38h did something similar with 8-bit images. Pixel array
> sharing only works with Java 1.6 due to due to bugs in earlier versions
> of Java.
>
> -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
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.