RFR: 8241840: Memoryleak: Closed focused Stages are not collected with Monocle. [v5]

Florian Kirmaier fkirmaier at openjdk.java.net
Thu Aug 13 19:27:26 UTC 2020

On Fri, 7 Aug 2020 20:39:56 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> As mentioned - I don't have a good setup to test this code on Windows.
>> But I've checked where focusedWindow/getFocusedWindow is used, and I can verify your assumption. I've searched through
>> the whole project and the variable is only used in the MonocleCode.
>> The fact that focusedWindow get's sometimes set is probably the cause of the irregular happening memoryleak on Window.
> In reading the comments, I thought you were going to revert the changes to `Window.java`? Or did I misinterpret what
> you said earlier?
> I can confirm that `focusedWindow` is no longer correctly set to the focused window when that Window is first shown (I
> tried this on Windows). This is true for apps with multiple windows as well as single Stage apps. I can also confirm
> that `focusedWindow` isn't used on any platform other than Monocle. Even so, since this change isn't needed it seems
> best to revert it.

The motivation for this change was, that I've seen a similar bug on native-windows without monocle.
In this case a leak happened related to the focusedWindow variable.
Sadly I don't have a test for this bug, because it is undeterministic.
For that reason, I thought it would make sense to keep this change, because I think it fixes it.
If I remember correctly, it was related to Stages which were focused but closed at the same time, which only weren't
collected because of the focusedWindow variable. Because the variable also isn't used on NativeWindows it doesn't seem
to do much harm.

I've now removed it, but it might be considered to be readded.


PR: https://git.openjdk.java.net/jfx/pull/153

More information about the openjfx-dev mailing list