[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Re: RFR: 8299423: JavaFX Mac system menubar leaks
From:       Florian Kirmaier <fkirmaier () openjdk ! org>
Date:       2022-12-31 10:16:56
Message-ID: 3K80MfoxpTIbClCixf3BF4YBCvpSMeUaftNra0dq-mY=.a3a11a56-1678-45d7-8a1d-c8531a77c740 () github ! com
[Download RAW message or body]

On Sat, 31 Dec 2022 04:18:09 GMT, Michael Strauß <mstrauss@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`.

@mstr2 
Thank you, this sounds interesting. I didn't know about it.
I guess this might allow me to remove these slightly complicated changes I've made.
I found it in the documentation here: \
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references
 I will try it out beginning next week.

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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic