On Thu, 2 Nov 2023 11:39:47 GMT, Johan Vos <j...@openjdk.org> wrote:

> When the Java layer removes a systemmenu, release the native resources 
> related to this systemmenu.
> This removes the strong JNI Global ref, which prevents its references from 
> being gc'ed.
> 
> The current implementation for the mac-specific system menu creates a menu, 
> but never releases its resources. In the `dealloc` of this menu, the strong 
> jni refs are deleted.
> With this PR, we now release the native resources associated with a menuItem 
> when that one is removed from a menu. A consequence is that this menuItem 
> should never be used after being removed from its current menu (e.g. it 
> should not be re-added, or its text/shortcut should not be altered). 
> The current implementation will create a new MacMenuDelegate every time a 
> menuItem is inserted into a menu, so there should be no references to the 
> native resources lingering.

This pull request has now been integrated.

Changeset: 8dd3c37c
Author:    Johan Vos <j...@openjdk.org>
URL:       
https://git.openjdk.org/jfx/commit/8dd3c37cae3dd52dc3a258033d0e8f168ceaf307
Stats:     80 lines in 4 files changed: 80 ins; 0 del; 0 mod

8318841: macOS: Memory leak with MenuItem when Menu.useSystemMenuBar(true) is 
used

Reviewed-by: kcr, jpereda

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

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

Reply via email to