<AWT Dev> [8u/9] Review request: JDK-8028486 [TEST_BUG] [macosx] java/awt/Window/WindowsLeak/WindowsLeak.java fails
anton.tarasov at jetbrains.com
Fri Apr 29 12:00:34 UTC 2016
Hi Sergey, Alexander,
Please review the fix:
bug: JDK-8028486 [TEST_BUG] [macosx] java/awt/Window/WindowsLeak/WindowsLeak.java fails
I’m copying my comment from CR:
Please open the attached screenshot [*], made with YourKit, where a chain of links is shown from the GC roots.
The frame is held by its peer which is held by CGLLayer which is held as validatedSrcData in the GL context.
The point is that the GL context doesn't cleanup the last state until under some conditions, which are not applicable to this scenario.
I'm not sure should the cleanup be triggered here or not, but the problem can be solved otherwise.
The point is that in the chain the CGLLayer instance has been disposed, in response to the frame disposal.
So, this is the only ref that holds it (the JNI ref is released by the native peer on disposal).
Thus, as the layer is disposed it can at least zero all the java refs it holds (this change already fixes the problem).
Then, the "layer" ref in CGLLayerSurfaceData should probably be made weak.
As to the “weak ref” mentioned in the comment. I didn’t do that, but if you find it reasonable I can add that change (or file a separate CR).
Also, the fix contains some additional cleanup (not related to this CR): two more JNI local refs leak, fixed.
More information about the awt-dev