RFR: 8294589: MenuBarSkin: memory leak when changing skin [v15]

Andy Goryachev angorya at openjdk.org
Thu Dec 1 23:33:47 UTC 2022


On Thu, 1 Dec 2022 22:45:20 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> just to be sure, which weak listener are you referring to?
>
> I didn't mean a weak listener, but a weak reference.  This line creates one:
> 
>      sceneListenerHelper = new ListenerHelper(MenuBarSkin.this);
> 
> I think a plain `new ListenerHelper()` would work correct here.  If you don't think so, I think it may be good to add a comment why the weak reference is needed to make the clean up work correctly.

I have to agree with you - it is not needed in this case.  The reason I put it there was "what if Stage.hide() gets called and the whole thing disappears, perhaps we want to make sure that all listeners that were registered via `sceneListenerHelper` get disconnected.  The thing is, all these listeners are registered against the scene belonging to that stage, so we are ok.

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

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


More information about the openjfx-dev mailing list