RFR: 6507038: Memory Leak in JTree / BasicTreeUI
Alexey Ivanov
aivanov at openjdk.org
Tue Jan 23 11:25:26 UTC 2024
On Thu, 18 Jan 2024 02:48:26 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> As mentioned in the comment
>
> https://github.com/openjdk/jdk/blob/36f4b34f1953af736706ec67192204727808bc6c/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java#L3283-L3284
>
> the components are to be removed when UI changes, so I guess it is expected to increase if UI is not changing (ie. in case tree is not visible) so I have removed at end when component is uninstalled at which point it is a leak too, if not removed..
> A testcase is hard to provide for this leak..it's all notional..
This is an interesting part… If the renderer component is added over and over again into `rendererPane` this creates a leak, especially if `currentCellRenderer.getTreeCellRendererComponent` returns a new component each time it's called.
To me, `rendererPane` should contain only one component — the one that's returned by appropriate cell renderer and that is currently used for painting, measuring etc.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17458#issuecomment-1905835853
More information about the client-libs-dev
mailing list