RFR: 8263402: MemoryLeak: Node hardreferences it's previous Parent after csslayout and getting removed from the scene
Ambarish Rapte
arapte at openjdk.java.net
Fri Mar 12 10:08:12 UTC 2021
On Wed, 10 Mar 2021 22:25:32 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:
> Fixing a memory leak.
> A node hard references its old parent after CSS layout and getting removed.
> This shouldn't be the case, this is very counterintuitive.
>
> The fix uses a WeakReference in CSSStyleHelper for firstStyleableAncestor.
> This should be fine because the CSS should only depend on it if it's still the real parent.
> In that case, it doesn't get collected.
modules/javafx.graphics/src/main/java/javafx/scene/CssStyleHelper.java line 180:
> 178: helper.cacheContainer = new CacheContainer(node, styleMap, depth);
> 179:
> 180: helper.firstStyleableAncestor = new WeakReference<>(findFirstStyleableAncestor(node));
Can you investigate for an alternative to set `firstStyleableAncestor` to null when the related `node` is removed from scenegraph
or
may be `null` the reference to `Node.styleHelper` itself when Node is removed from scenegraph. This will result in recreating the `Node.styleHelper` next time when it is added back to scenegraph.
-------------
PR: https://git.openjdk.java.net/jfx/pull/424
More information about the openjfx-dev
mailing list