bigdataviewer / bigdataviewer-core

ImgLib2-based viewer for registered SPIM stacks and more
BSD 2-Clause "Simplified" License
33 stars 35 forks source link

Make sure the PainterThread does not cause a memory leak #163

Closed maarzt closed 1 year ago

maarzt commented 1 year ago

This PR changes the PainterThread to use WeakReference. This ensure that the paintable can be garbage collected without the painter thread intervening.

The PR also adds a unit test to ensure that the garbage collection works as expected.

Additionally notify() is replaced with notifyAll(). It doesn't make a difference in our case. But notifyAll() is the preferred method to use because it more reliable wakes up the waiting threads.

maarzt commented 1 year ago

This PR is related to a discussion and memory leak in Mastodon, see https://github.com/mastodon-sc/mastodon/pull/244#issuecomment-1573414400.