Fix OldSystemTest gc
Calls System.gc + System.runFinalization since System.gc is usually a NOP.
Bug: 21211315
Change-Id: Ib816521c6ed43eca437bf8fa961650f7fb96ba61
diff --git a/luni/src/test/java/libcore/java/lang/OldSystemTest.java b/luni/src/test/java/libcore/java/lang/OldSystemTest.java
index dee5bdd..5a9fc2e 100644
--- a/luni/src/test/java/libcore/java/lang/OldSystemTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldSystemTest.java
@@ -260,12 +260,14 @@
while(rt.freeMemory() < beforeTest * 2/3) {
vec.add(new StringBuffer(1000));
}
- long beforeGC = rt.freeMemory();
+ long beforeGC = rt.totalMemory() - rt.freeMemory();
+ vec = null;
System.gc();
- long afterGC = rt.freeMemory();
+ System.runFinalization();
+ long afterGC = rt.totalMemory() - rt.freeMemory();
assertTrue("memory was not released after calling System.gc()." +
"before gc: " + beforeGC + "; after gc: " + afterGC,
- beforeGC < afterGC);
+ beforeGC >= afterGC);
}
public void test_getenv() {