Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix garbage collection for the SpatioTemporalIndexImpRebuilderThread #14

Merged
merged 2 commits into from
May 31, 2023

Conversation

maarzt
Copy link
Contributor

@maarzt maarzt commented May 25, 2023

This PR fixes a bug in the SpatioTemporalIndexImpRebuilderThread that prevented the SpatioTemporalIndexImp and hence the ModelGraph in Mastodon from beeing garbage collection. See issue mastodon-sc/mastodon#225.

The bug fixed in this PR was causing the following test to fail:

package org.mastodon.mamut.tomancak;

import org.junit.Test;
import org.mastodon.mamut.model.Model;

public class MastodonMemoryTest
{
	@Test
	public void test() {
		for ( int i = 0; i < 100; i++ )
		{
			new Model();
		}
	}
}

(Note: There are other bugs in Mastodon that need to be solved before mastodon-sc/mastodon#225 can be closed.)

@maarzt maarzt requested review from tpietzsch and tinevez May 25, 2023 09:02
Previously the SpatialTemporalIndexImpRebuilderThread was holding a strong
reference to the SpatialTemporalIndexImp in its run method, at all time.
This prevented the spatial temporal index from being garbage collected,
which also meant that the thread never terminated.
…meout)

The Thread previously used Object.wait(timeout) for waiting.
Object.wait(timeout) is part of complicated API for thread synchronization
which should be avoided.

Thread.sleep(timeout) is a simple replacement that works perfectly fine
for our use case.
@maarzt maarzt merged commit ccacc4d into master May 31, 2023
1 check passed
@maarzt maarzt deleted the fix-garbage-collection branch May 31, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants