RFR: 8299423: JavaFX Mac system menubar leaks

Michael Strauß mstrauss at openjdk.org
Sat Dec 31 04:20:52 UTC 2022


On Fri, 30 Dec 2022 09:41:46 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:

> This PR fixes the leak in the mac system menu bar.
> 
> Inside the native code, NewGlobalRef is called for the callable.
> Which makes it into a "GC-Root" until DeleteGlobalRef is called.
> 
> The DeleteGlobalRef is never called for the MenuEntry, if it's removed from the menu without removing it's callable.
> This PR adds logic, whether the Menu is inserted. If it's not inserted in a Menu anymore, then DeleteGlobalRef is called, by calling `_setCallback` with the callable "null".
> 
> The unit test verifies, that this bug happened without this change, but no longer happens with this change.

Have you considered storing a weak global reference to the callback instead of a strong global reference?
That might also solve the problem without keeping track of the callback in `MacMenuDelegate`.

-------------

PR: https://git.openjdk.org/jfx/pull/987


More information about the openjfx-dev mailing list