RFR: 8262518: SwingNode.setContent does not close previous content, resulting in memory leak [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Thu Aug 24 03:17:03 UTC 2023
On Wed, 23 Aug 2023 14:57:31 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> DisposerRecord leak fix
>
> modules/javafx.swing/src/main/java/javafx/embed/swing/SwingNode.java line 368:
>
>> 366: private void setContentImpl(JComponent content) {
>> 367: if (lwFrame != null) {
>> 368: rec.dispose();
>
> is it possible for `rec` to be null at this point?
> would it make sense to rewrite this code block as
>
> if(rec != null) {
> rec.dispose();
> rec = null;
> }
> if(disposeRecRef != null) {
> Disposer.removeRecord(...)
> disposerRecRef = null;
> }
> if(lwFrame != null) {
> lsFrame = null;
> }
>
> ?
If `lwFrame` is not null, little chance of `rec` to be null at this point as unlike PR#1178 there's no multiple threads involved, only EDT, so no race condition causing class variables to null out,
but anyways I have added null check to be safe..
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1219#discussion_r1303735328
More information about the openjfx-dev
mailing list