Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8244297: Provide utility for testing for memory leaks #204

Original file line number Diff line number Diff line change
@@ -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 {