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

John Hendrikx jhendrikx at openjdk.org
Wed Aug 23 10:16:04 UTC 2023


On Wed, 23 Aug 2023 03:23:17 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 one additional commit since the last revision:
> 
>   Optimize without WeakReference

modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/Disposer.java line 94:

> 92:     public static void removeRecord(DisposerRecord rec) {
> 93:         disposerInstance.records.remove(rec);
> 94:     }

Sorry, but this won't work.  The record is not the key, see this line:

             disposerInstance.records.put(ref, rec);

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1219#discussion_r1302801415


More information about the openjfx-dev mailing list