-
Notifications
You must be signed in to change notification settings - Fork 188
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
find/replace overlay: clean up PreferenceChangeListener #1948
find/replace overlay: clean up PreferenceChangeListener #1948
Conversation
The PreferenceChangeListener now starts listening when an Overlay was created and stops listening once the Overlay is disposed of. Fixes a previous resource leak. fixes jdt#1444
@jukzi can you please look into this and tell me whether it improves things? When/How are the resource-leak tests ran? |
I did not know how to reproduce the test error locally so i can not verify locally if it is solved. |
Test Results 1 210 files - 605 1 210 suites - 605 1h 3m 30s ⏱️ - 27m 37s Results for commit 7abb920. ± Comparison against base commit 385b30b. This pull request skips 3 tests.
|
|
||
FindReplaceOverlayFirstTimePopup.displayPopupIfNotAlreadyShown(shellToUse); | ||
} | ||
|
||
overlay.setPositionToTop(shouldPositionOverlayOnTop()); | ||
overlay.open(); | ||
overlay.getShell().addDisposeListener(__ -> removeDialogPreferenceListener()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to move overlayDialogPreferenceListener
to the FindReplaceOverlay
itself? There one could simply add listener in constructor and remove on close().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had moved this listener out of the FindReplaceOverlay
as a response to @HeikoKlare's comment: #1192 (comment)
I believe that he is right and believe that it is indeed best if the Overlay is independent from the "global parametrization".
Just start the test from IDE as any other test, it will fail saying that JVM args should be modified, so proceed and add all the This change fixes the leak, but as said above, I would prefer the listener would be moved from the action to the overlay class so no memory leak should happen by design. |
@iloveeclipse the leak does NOT happen in the find/replace overlay. The leak happens because I am not notified when the Action is disposed of and since the PreferenceChangeListeners is a field of the Action, I could not know when it was destroyed. |
Sure, I never said that. What I mean is that if you would move listener from the action to the overlay, no leak would happen.
Right, but why should action listen to overlay preferences in first place, if it's what the overlay should care about. |
@iloveeclipse a leak would still happen: the listener is attached to the Preferences object of Eclipse, the Overlay still would have to implement it's own "dispose"-method which then disposes of this listener. The action parametrizes the overlay as it is the "consumer" of the overlay. |
@Wittmaxi can you explain where / why you need to listen to preference changes? Maybe one can solve it without a listener or using the listener on a different place... |
@laeubi When changing the Overlay preferences from "display overlay on top" to "display overlay on bottom", I want to be able to instantly display the overlay on the bottom without needing to close/re-open the overlay @iloveeclipse is it okay for you if we create an issue to discuss this a bit later down the line (when Heiko is back from Vacation)? For now, I believe that it is most important to fix the JavaLeakTest, the design decision of "who is responsible for parametrizing the overlay?" is out of scope for this PR. |
i did that but the test was green for me locally. |
Haven't checked the code, might be something not possible to test on Windows.
OK |
If I recap correctly, the reason for not wanting the preference listener in the
Anyway, is this still an open point for discussion and has the solution implemented so far to be revised or it okay for everyone? |
The PreferenceChangeListener now starts listening when an Overlay was created and stops listening once the Overlay is disposed of. Fixes a previous resource leak.
fixes jdt#1444