trackmate-sc / TrackMate

TrackMate is your buddy for your everyday tracking.
https://imagej.net/plugins/trackmate
GNU General Public License v3.0
158 stars 75 forks source link

TrackMate does not free up RAM when closing. #185

Open tinevez opened 3 years ago

tinevez commented 3 years ago

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.

So here is my memory leak.

imagesc-bot commented 3 years ago

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

NicoKiaru commented 3 years ago

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

tinevez commented 3 years ago

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

tinevez commented 3 years ago

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

ctrueden commented 3 years ago

@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.

NicoKiaru commented 3 years ago

I've got this:

image

A lambda in FilterGuiPanel

NicoKiaru commented 3 years ago

Maybe linked to a thread which is not stopped: image

NicoKiaru commented 3 years ago

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

image

NicoKiaru commented 3 years ago

Add after removing the ImagePlus keys in displayers of SpotEditTool:

image

Not sure this is going to end