On Thu, 13 Oct 2022 22:06:15 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> Since this was quite wordy, and since pictures are worth a thousand words... >> >> Here is the situation when you have a Label with its Skin: >> >>  >> >> When that Skin is replaced, dispose is called which toggles `active` to >> `false`. Furthermore, the Label will no longer reference the Skin. This >> image then shows the state of the references, and which objects can be GC'd: >> >>  > > Thank you for explanations, @hjohn . > > This *might* work for Skins, of course, though it is not exactly what is > needed for Skins (I will explain why in > https://github.com/openjdk/jfx/pull/908 because of context). > > In the context of this PR, I can see how a memory leak can be created when a > developer has the `active` property as long lived and that would prevent the > whole chain from being collected. An example would be trying to attach to > the Window.showingProperty(), adding listeners that reference Nodes that are > supposed to be GC'd when removed from the said window (dynamically creating > detail panes as response to selection event, for example). > > I think what you propose here is good, but, as any other place where > listeners are added, must be used with caution (may be reflect that fact in > javadoc?) And, more specifically, is there a way to break the strong reference between the `active` property and the dependent fluent chain? ------------- PR: https://git.openjdk.org/jfx/pull/830