On Tue, 23 Jan 2024 04:58:00 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
>> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java line
>> 1338:
>>
>>> 1336: if(rendererPane != null) {
>>> 1337: if (!tree.isVisible()) {
>>> 1338: rendererPane.removeAll();
>>
>> Wouldn't it be enough to remove `rendererPane` from and assign `null` to it?
>>
>> It's done this way in `BasicTableUI` and `BasicListUI`:
>> https://github.com/openjdk/jdk/blob/0d8543d6773a516dad54038070dce507179d0709/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java#L1656-L1658
>> and
>> https://github.com/openjdk/jdk/blob/0d8543d6773a516dad54038070dce507179d0709/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java#L986-L988
>
> It is already been done in `completeUIUninstall` called from `uninstallUI`
> `rendererPane.removeAll `is done to remove all components that are added in
> `getNodeDImensions` which gets removed in `paint` but if tree is not visible,
> then `paint `is not called so those components are not removed, which I am
> trying to do now in `uninstallUI `by checking tree visibility condition
Okay, I see it. Then the added lines in `uninstallComponents` aren't needed
because `rendererPane` is assigned `null` in `completeUIUninstall` which is
called right after `uninstallComponents`, therefore `rendererPane` itself and
all the components added into it are eligible for garbage collection.
Where is the memory leak then?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17458#discussion_r1463114166