RFR: 8293444: Creating ScrollPane with same content component causes memory leak [v2]
Ambarish Rapte
arapte at openjdk.org
Wed Sep 28 08:48:55 UTC 2022
On Fri, 16 Sep 2022 18:04:07 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Using Weak*Listeners eliminates the memory leak.
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
>
> 8293444: memory buddy
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/ScrollPaneSkinTest.java line 36:
> 34: import org.junit.Before;
> 35: import org.junit.Ignore;
> 36: import org.junit.Test;
These got moved from line 51(without this PR), can restore this change.
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/ScrollPaneSkinTest.java line 875:
> 873:
> 874: /**
> 875: * checks that there are no memory leaks when replacing scroll pane content
Minor rephrasing:
* Test that ScrollPane object is not leaked when 'same' node
* is used as content for different ScrollPane objects.
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/ScrollPaneSkinTest.java line 878:
> 876: */
> 877: @Test
> 878: public void checkMemoryLeaks_JDK_8293444() {
may be rename to something similar as : `testScrollPaneObjLeakWhenUsedSameContent`
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/ScrollPaneSkinTest.java line 887:
> 885: stage.setScene(new Scene(bp));
> 886: stage.setWidth(600);
> 887: stage.setHeight(600);
Minor: These are not required for the test. so can remove.
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/ScrollPaneSkinTest.java line 912:
> 910:
> 911: // one instance is still held by the 'content' label
> 912: assertTrue("uncollected objects=" + ct, ct <= 1);
May be the assert can be updated to:
assertEquals("One instance should be held by the 'content' label", 1, ct);
content = null;
ct = 0;
for (WeakReference<ScrollPane> ref : refs) {
JMemoryBuddy.checkCollectable(ref);
if (ref.get() != null) {
ct++;
}
}
assertEquals(ct + " References of ScrollPane are not freed.", 0, ct);
-------------
PR: https://git.openjdk.org/jfx/pull/900
More information about the openjfx-dev
mailing list