RFR: 8262518: SwingNode.setContent does not close previous content, resulting in memory leak [v4]

Andy Goryachev angorya at openjdk.org
Thu Aug 24 15:22:37 UTC 2023


On Thu, 24 Aug 2023 03:17:03 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Issue is when setting the content of a SwingNode, the old content is not garbage collected owing to the fact
>> JLightweightFrame is never being released by SwingNodeDisposer
>> 
>> The SwingNodeDisposer holds an hard pointer to the JLightweightFrame that prevents its collection
>> 
>> Modified `SwingNode.setContentImpl`  function to use a WeakReference to properly release the memory.
>
> Prasanta Sadhukhan has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - javadoc, null check
>  - javadoc, null check

Tested with the code example in the ticker.  Seems to work, the "Panels in memory" stays around 2, occasionally goes to 30-40 but then comes down to 2 pretty quickly.  Same behavior even when `Thread.sleep(1);`

Questions:
1. the JBS ticket refers to 3 other tickets - are we sure these are exact duplicates?
2. the JBS talks about 1.8.0.271 - do we need to backport this fix to java8?

-------------

Marked as reviewed by angorya (Reviewer).

PR Review: https://git.openjdk.org/jfx/pull/1219#pullrequestreview-1593867401


More information about the openjfx-dev mailing list