RFR: 8319779: SystemMenu: memory leak due to listener never being removed [v4]
John Hendrikx
jhendrikx at openjdk.org
Tue Dec 26 15:32:47 UTC 2023
On Tue, 26 Dec 2023 10:24:42 GMT, Johan Vos <jvos at openjdk.org> wrote:
> I'm still looking into adding a test. The challenge is that the (previously) uncollected items are of type `com.sun.glass.ui.MenuItem`, and afaik we can't use JMemoryBuddy to check the collectable state of instances on the heap that we don't have a reference to ourselves. I see 2 options:
>
> * a unit test, with new shim classes so that we get access to `com.sun.glass.ui.MenuItem` from the test. The problem here is that this quickly becomes a test for the shim class and not for the real classes
> * a systemtest that can somehow inspect the heap and count the instances of `com.sun.glass.ui.MenuItem`
Perhaps add a package private method to get access to `GlassSystemMenu#systemMenus` (or use reflection)? I think you could then put a weak reference on the returned list (or items) and see if that disappears.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1283#issuecomment-1869617031
More information about the openjfx-dev
mailing list