TrackMate icon indicating copy to clipboard operation
TrackMate copied to clipboard

TrackMate does not free up RAM when closing.

Open tinevez opened this issue 2 years ago • 9 comments

If I track a 250MB image (one coming from the ISBI SPT challenge, VIRUS snr 7 density high) I see it at the end of the tracking. I document here quickly the RAM usage followed with the Monitor Memory tool (it is not relevant to check RAM usage from the Windows tool). Every value I report are the one reported by the tool after garbage collection. I used the devel version of TrackMate for the test.

  • Opening Fiji 43 MB

  • Opening the Image 295 MB

  • Launching TrackMate 480 MB

  • In the config panel of the LoG detector, after preview 310 MB (sigh)

  • If I close TrackMate UI and the image now, the RAM usage goes down to 58 MB, which is what we expect.

  • After full detection (diameter 5, threshold 50, no initial thresholding, I got about 100k spots), in the spot filter panel 530 MB

  • If I close TrackMate now, it does NOT give back the RAM. I still use 530 MB

So here is my memory leak.

tinevez avatar Jul 27 '21 15:07 tinevez

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/trackmate-does-not-free-up-ram-when-closing/54922/4

imagesc-bot avatar Jul 27 '21 15:07 imagesc-bot

@tinevez I'm curious to know how you deal with this. Visualvm + eclipse MAT?

NicoKiaru avatar Jul 27 '21 15:07 NicoKiaru

I am actually using the YourKit Java profiler, making a RAM snapshot.

tinevez avatar Jul 27 '21 16:07 tinevez

Hum I am afraid I am failing big time on this one. I cannot manage to identify the culprit with my method. Still trying.

tinevez avatar Jul 27 '21 16:07 tinevez

@tinevez Just a guess: is it possible that some JFrame or JDialog objects are not being disposed when closed? I see you have some setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE ); calls, but there are quite a few different new JFrame and extends JFrame invocations in TrackMate, most of which are not set to dispose on close.

I pushed a branch dispose-on-close where I tried to set the default close operation to dispose for all frames I could quickly find. But I don't have time to test it now, sorry. Maybe you could try it and see if the memory leak persists?

Do you have any frames that you allow the user to toggle visibility by closing them temporarily? Like, they can press the X, but then another button elsewhere can show the frame again? If so, we'd need to do something more clever to dispose such frames at the proper time later.

ctrueden avatar Jul 27 '21 19:07 ctrueden

I've got this:

image

A lambda in FilterGuiPanel

NicoKiaru avatar Jul 28 '21 14:07 NicoKiaru

Maybe linked to a thread which is not stopped: image

NicoKiaru avatar Jul 28 '21 14:07 NicoKiaru

When butchering out the OnRequestUpdater thread and the PainterThread in WizardPanel I get this chain:

image

NicoKiaru avatar Jul 28 '21 16:07 NicoKiaru

Add after removing the ImagePlus keys in displayers of SpotEditTool:

image

Not sure this is going to end

NicoKiaru avatar Jul 28 '21 17:07 NicoKiaru