JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.34k stars 266 forks source link

Memory leak for property change listeners in shared UIs #471

Closed ingokegel closed 2 years ago

ingokegel commented 2 years ago

The cached property change listeners in shared UIs strongly reference an instance for which listeners were installed.

2022-01-24_12-53-56

Should this listener maybe be stored in a client property of the component instead of in a field in the shared UI so that the component can be garbage collected?

DevCharly commented 2 years ago

Many thanks for reporting.

I've added this property change listeners to FlatLaf v2 for styling support. Unfortunately, the implementation is wrong for shared UIs.

A new instance of the listener is created for each component, but stored in a shared UI instance and overwrites previous listener... So the there is always a reference to the last created component in the last listener... Previously created components should be not referenced because their listeners are not referenced.

Working on a fix...

DevCharly commented 2 years ago

Should be fixed in latest 2.0.1-SNAPSHOT https://github.com/JFormDesigner/FlatLaf#snapshots

Please give it a try

ingokegel commented 2 years ago

Thank you, now it looks good in my tests!