-
Notifications
You must be signed in to change notification settings - Fork 25
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 LegacyImageMap's ImagePlus references #67
Comments
|
Right now, if you open an image, close it, then open it again, it will have |
My analysis revealed that the behavior is due to That is all correct, except that it looks as if the display object is never removed from the To help debugging this further, I made a unit test. |
|
So @dscho, to be clear: you think the As discussed in person, I will tackle the disposal of |
At the moment, it does not. Due to the legacy thread group hacks that do not work with the way we call commands at all. I have some hacky removal in place but it needs a lot of cleaning up and a lot of testing before I am comfortable with merging it into
I think with your work, my clean up should completely get rid of the references. |
|
@hinerm sorry for leaving this so much in limbo and cryptic... The changes I made are in one monster |
|
@dscho no apologies necessary. Just wanted to know where things were at so I can start working on it :) |
|
@dscho @ctrueden apologies that I was unable to understand exactly what was trying to be accomplished in the I'll look at |
|
@hinerm oh, thank you! I did not get around to split things up, and the only reason this is on |
Currently, the
LegacyImageMaphas the following issues regarding how it handlesImagePlusreferences:WeakReferences. ASetofWeakReferencesis used, but eachWeakReferenceis unique so it's always added to the set. What we want is aWeakSeteffectively. See this SO question for suggestions (such as using aWeakHashMapandCollections.newSetFromMap).ConcurrentHashMap. This creates strong references to theImagePluses which prevents them from being garbage collected.One step in the desired direction could be to javassist the
ImagePlus#closemethod to deregister anImagePlusfrom theLegacyImageMap. However, the ImageJ macro language does not actually close anImagePlususing theclose()method.So it seems like we either need to do more aggressive javassisting or move to
WeakReferences.If we do go to full
WeakReferenceswe will also need to disable modern mode, as we will no longer be able to keep references toImagePluses in modern mode. In legacy mode, theWindowManageris what keepsImagePluses from being garbage collected. We could populate this structure in modern mode.. but it wouldn't work when headless. So we also need a better understanding of the legacy mappings when headless to properly determine how to proceed.The text was updated successfully, but these errors were encountered: