On Wed, 10 Mar 2021 22:30:27 GMT, Kevin Rushforth <k...@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.
>
> Since this touches CSS, it needs a second reviewer.

I think others can review this. I do have a couple questions:
1. In general, I don't like the idea of just making everything a weak 
reference, since it often masks a design issue. Two exceptions are for caches 
and for back references to a "parent" or controlling object that has a strong 
reference to "this" object (most of our weak listeners fall into this latter 
pattern). It sounds like latter case also applies here. Can you confirm that?
2. Have you verified that all the places that use the fields that are now 
WeakReferences are prepared to deal with `get()` returning a null object?

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

PR: https://git.openjdk.java.net/jfx/pull/424

Reply via email to