WeakXXListener - when not to use?

Jeanette Winzenburg fastegal at swingempire.de
Wed Mar 25 10:13:24 UTC 2020


Currently, there are two open pull requests (#147 and #148) for fixing  
memory leaks in controls/skin with the same comment from Kevin:

"Using a WeakListener is certainly easier, but runs the risk of the  
listener being removed too early and not cleaning up after itself."

Looks like I can't come up with a scenario where this might happen -  
as long as the owner (f.i. a control) of the instance that mananges  
the listener (f.i. a selectionModel) on a property of the owner keeps  
a strong reference to the manager.

Questions:

- what to watch out for to safely exlude any unwanted self-removal?
- how to test?

-- Jeanette



More information about the openjfx-dev mailing list