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

Mastodon Memory Leak #225

Open
2 tasks done
maarzt opened this issue Mar 8, 2023 · 8 comments
Open
2 tasks done

Mastodon Memory Leak #225

maarzt opened this issue Mar 8, 2023 · 8 comments
Labels

Comments

@maarzt
Copy link
Contributor

maarzt commented Mar 8, 2023

Problem description

I noticed that mastodon objects like WindowManger, ProjectManager, AppModel etc. don't get garbage collected after the project is closed.

This can be a problem for users. Fiji might run out of memory when opening a large number of Mastodon projects, one after the other. The Eclipse Memory Analyzer is a handy tool to inspect such problems. The org.mastodon.spatial.SpatioTemporalIndexImpRebuilderThread seems to stay in memory and keeps a reference to the ModelGraph.

TODOs

  • Find why the SpatioTemporalIndexImpRebuilderThread does not stop after Mastodon is closed. Fix that problem.
  • Check if garbage collection properly cleans up the Mastodon WindowManager and ModelGraph.

Expected Behavior

All Mastodon related objects (WindowManager, ProjectManager, AppModel, ModelGraph, etc. ) get garbage collected after a Mastodon project is closed.

@maarzt maarzt added the bug label Mar 8, 2023
@tinevez
Copy link
Contributor

tinevez commented Mar 8, 2023

Argh the horror.

@maarzt
Copy link
Contributor Author

maarzt commented May 8, 2023

The following few lines of code are enough to trigger an OutOfMemoryException:

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();
		}
	}
}

The problem seems to be related to the UndoRedoStack. See stack trace:

java.lang.OutOfMemoryError: Java heap space

	at org.mastodon.undo.ByteArrayUndoRedoStack.<init>(ByteArrayUndoRedoStack.java:122)
	at org.mastodon.undo.GraphUndoRedoStack.<init>(GraphUndoRedoStack.java:90)
	at org.mastodon.undo.GraphUndoRecorder.<init>(GraphUndoRecorder.java:98)
	at org.mastodon.mamut.model.Model.<init>(Model.java:178)
	at org.mastodon.mamut.model.Model.<init>(Model.java:122)
	at org.mastodon.mamut.tomancak.MastodonMemoryTest.test(MastodonMemoryTest.java:12)

stefanhahmann added a commit to mastodon-sc/mastodon-deep-lineage that referenced this issue May 8, 2023
…g tests.

This is necessary, since there is a memory leak in mastodon (mastodon-sc/mastodon#225)
stefanhahmann added a commit to mastodon-sc/mastodon-deep-lineage that referenced this issue May 8, 2023
…g tests.

This is necessary, since there is a memory leak in mastodon (mastodon-sc/mastodon#225)
stefanhahmann added a commit to mastodon-sc/mastodon-deep-lineage that referenced this issue May 8, 2023
This is necessary, since there is a memory leak in mastodon (mastodon-sc/mastodon#225)
stefanhahmann added a commit to mastodon-sc/mastodon-deep-lineage that referenced this issue May 8, 2023
This is necessary, since there is a memory leak in mastodon (mastodon-sc/mastodon#225)
@maarzt maarzt mentioned this issue May 31, 2023
2 tasks
@stefanhahmann
Copy link
Collaborator

@maarzt Could you ask for review/approval/merge of the related PR bigdataviewer/bigdataviewer-core#163 so that the temporarily introduced PainterThread of this PR does not live longer than necessary?

@tpietzsch
Copy link
Contributor

I'll review it today

@tpietzsch
Copy link
Contributor

merged and released with bigdataviewer-core-10.4.7

@tinevez
Copy link
Contributor

tinevez commented Jun 14, 2023

Could we depend on bigdataviewer-core-10.4.7 in mastodon and use the code from there? Or do we have specifics in Mastodon?

@maarzt
Copy link
Contributor Author

maarzt commented Jun 20, 2023

This issue if fixed with the following PRs being merged and mastodon-graph-1.0.0-beta-24 and bigdataviewer-core-10.4.7 being released:

@maarzt maarzt closed this as completed Jun 20, 2023
@tinevez
Copy link
Contributor

tinevez commented Aug 22, 2023

Hello @maarzt
Really thank you the tests you build sweat talent and skills.

Unfortunately I tested the org.mastodon.mamut.GarbageCollectionTest and it still fails, even with

  • mastodon-graph 1.0.0-beta-24
  • bigdataviewer-core 10.4.7
    This horrible issue is not over :(

@tinevez tinevez reopened this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants