RFR: 8307538: Memory leak in TreeTableView when calling refresh [v7]
Marius Hanl
mhanl at openjdk.org
Tue Jun 6 17:23:14 UTC 2023
On Tue, 6 Jun 2023 15:56:45 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> modules/javafx.controls/src/main/java/javafx/scene/control/skin/TreeTableRowSkin.java line 117:
>>
>>> 115: TreeTableView<T> treeTableView = getSkinnable().getTreeTableView();
>>> 116: if (treeTableView == null) {
>>> 117: registerInvalidationListener(getSkinnable().treeTableViewProperty(), (x) -> {
>>
>> One question here: Why does this prevent the leak but the ListenerHelper does not?
>
> The difference is that registerInvalidationListener() adds a weak listener, while ListenerHelper adds a strong listener.
>
> It is possible to use ListenerHelper here, at the expense of more complicated code since we'd need to explicitly disconnect the listener when tableViewProperty value gets set.
>
> Another solution would involve adding a method to add a weak listener to the ListenerHelper to avoid explicit cleanup, or
>
> Go back to the original code which used register/unregister*Listener **in this particular case**.
Okay, makes sense.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1129#discussion_r1220038627
More information about the openjfx-dev
mailing list