From 6ece3a7a662bc88407ae5a3f342bb5dbb6688f92 Mon Sep 17 00:00:00 2001 From: floriankirmaier Date: Wed, 28 Oct 2020 10:40:02 +0100 Subject: [PATCH] JDK-8244297 more improvements based on code-review --- .../src/test/java/test/util/memory/JMemoryBuddy.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/javafx.base/src/test/java/test/util/memory/JMemoryBuddy.java b/modules/javafx.base/src/test/java/test/util/memory/JMemoryBuddy.java index 19816bfe769..543f404677d 100644 --- a/modules/javafx.base/src/test/java/test/util/memory/JMemoryBuddy.java +++ b/modules/javafx.base/src/test/java/test/util/memory/JMemoryBuddy.java @@ -131,7 +131,7 @@ private static int checkCollectable(int stepsLeft, WeakReference weakReference) } /** - * Checks whether the content of the WeakReference can not be collected. + * Checks whether the content of the WeakReference cannot be collected. * @param weakReference The WeakReference to check. */ public static void assertNotCollectable(WeakReference weakReference) { @@ -141,11 +141,14 @@ public static void assertNotCollectable(WeakReference weakReference) { } /** - * Checks whether the content of the WeakReference can not be collected. + * Checks whether the content of the WeakReference cannot be collected. * @param weakReference The WeakReference to check. - * @return Returns true, when the provided WeakReference can not be collected. + * @return Returns true, when the provided WeakReference cannot be collected. */ public static boolean checkNotCollectable(WeakReference weakReference) { + createGarbage(); + System.gc(); + System.runFinalization(); createGarbage(); System.gc(); return weakReference.get() != null; @@ -212,11 +215,8 @@ public void setAsReferenced(Object ref) { throw new AssertionError("The following references should be collected: " + toBeCollectedMarked + " and " + toBeNotCollected.size() + " should not be collected: " + toBeNotCollectedMarked); } } - - } - static void createHeapDump() { if (createHeapdump) { try {