mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
66 stars 20 forks source link

Fix Garbage Collection #270

Closed maarzt closed 6 months ago

maarzt commented 8 months ago

The unit test in GarbageCollectionTest fails currently, when executed with an enabled graphics environement. This is because TagSetDialog, FeatureComputationDialog and PreferencesDialog are no longer disposed properly since the latest changes to the app model.

This PR fixes the problem by adding the dialog's dispose() methods to the ProjectModel.projectClosedListeners().

maarzt commented 8 months ago

fixes #269

tinevez commented 8 months ago

Hello @maarzt Unfortunately the test still fails on my side (Mac book pro), using maven in a command line or from Eclipse.

The test that fails:

Running org.mastodon.mamut.GarbageCollectionTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 7.252 sec <<< FAILURE!
java.lang.AssertionError: The garbage collection failed to clean ModelGraph. expected null, but was:<org.mastodon.mamut.model.ModelGraph@6487f7f8>
    at org.junit.Assert.fail(Assert.java:89)
    at org.junit.Assert.failNotNull(Assert.java:756)
    at org.junit.Assert.assertNull(Assert.java:738)
    at org.mastodon.mamut.GarbageCollectionTest.testIfMastodonIsGarbageCollectable(GarbageCollectionTest.java:93)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
maarzt commented 8 months ago

Oh, this is a pity. I didn't expect the test to fail on other platforms. I thought the Java Swing implementation on linux would be the most unforgiving in terms a memory leaks. But the test passes on my machine. Could you please double check if everything is setup correctly?

Is your working directory clean? Did you checkout the correct "fix-garbage-collection" branch. Please make sure to run mvn clean before running the tests. (I had the problem on machine: The test was failing after I switched to the fix-garbage-collection git branch. Calling mvn clean fixed the problem. So I hope that's the same on your machine.)

@stefanhahmann Could you test if the test passes on windows?

maarzt commented 8 months ago

Ok, @stefanhahmann did run the GarbageCollectionTest on Windows. It passes.

@tinevez I hope the test will pass on your Mac after executing "mvn clean". Worst case, the test continues to fail. This would likely mean, that there is a platform specific memory leak on Mac. We could have a video call, and try to debug the problem together. I can show you how I use the Eclipse Memory Analyzer to find memory leaks.