RFR: 8315317: Add test for JDK-8262518 [v2]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Sep 4 06:35:45 UTC 2023
On Fri, 1 Sep 2023 14:38:16 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> tests/system/src/test/java/test/javafx/embed/swing/SwingNodeContentMemoryLeakTest.java line 116:
>>
>>> 114: System.out.println("iteration " + count + " Panels in memory: "
>>> 115: + panelCount + " fail " + fail);
>>> 116: assertFalse(fail > 2);
>>
>> I actually seen the number to shoot up to 38 (albeit with Thread.sleep(1)). I wonder if there is a better way to detect failure? May be the fact that the 'panelCount` is ever increasing is the sign of failure, whereas if at least one time it's dropping we have succeeded.
>> Or perhaps look at the count when the test complete and fail if panelCount < (attempts / 2) or something
>
> I recommend using `JMemoryBuddy`, which is what we use for all of our newer memory leak tests.
I am not sure I understand the nuances of JMemoryBuddy. I tried using `JMemoryBuddy.assertCollectable` but it fails with
Exception in thread "Thread-7" java.lang.AssertionError: Content of WeakReference was not collected. content: javax.swing.JPanel[,0,0,0x0,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
at test.util.memory.JMemoryBuddy.assertCollectable(JMemoryBuddy.java:91)
maybe because the test doesn't cause SwingNode content count to 0.
But I have modified the test to have better way of detecting failure as suggested and check for total count at end which normally increases without fix..I hope that should be good enough to ensure it fails without the fix and pass with it..
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1228#discussion_r1314491398
More information about the openjfx-dev
mailing list