diff options
author | 2022-07-11 15:26:22 -0700 | |
---|---|---|
committer | 2022-07-11 16:40:51 -0700 | |
commit | 0f8fc9a0c985a0418d13fd8026df55e12253aed9 (patch) | |
tree | 012134614c1b5fe69085bf478e1090bad0f18115 | |
parent | 87daf9f5ccf3697133784af2aed98826c5eb662a (diff) |
Make LoadClass collect garbage as promised
I found no clients or tests for this. But System.gc() by itself does
nothing, so the original version clearly does not work as intended. The
revised version may.
Bug: 193185229
Test: Treehugger
Change-Id: Ie4e59834a6dd23d83f30f8d0aaa1bf6d124ade91
-rw-r--r-- | tools/preload/loadclass/LoadClass.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/preload/loadclass/LoadClass.java b/tools/preload/loadclass/LoadClass.java index a71b6a8b145e..3f6658ab8c65 100644 --- a/tools/preload/loadclass/LoadClass.java +++ b/tools/preload/loadclass/LoadClass.java @@ -14,8 +14,8 @@ * limitations under the License. */ -import android.util.Log; import android.os.Debug; +import android.util.Log; /** * Loads a class, runs the garbage collector, and prints showmap output. @@ -28,7 +28,7 @@ class LoadClass { System.loadLibrary("android_runtime"); if (registerNatives() < 0) { - throw new RuntimeException("Error registering natives."); + throw new RuntimeException("Error registering natives."); } Debug.startAllocCounting(); @@ -46,7 +46,7 @@ class LoadClass { } } - System.gc(); + Runtime.getRuntime().gc(); int allocCount = Debug.getGlobalAllocCount(); int allocSize = Debug.getGlobalAllocSize(); @@ -73,7 +73,7 @@ class LoadClass { response.append(',').append(freedCount); response.append(',').append(freedSize); response.append(',').append(nativeHeapSize); - + System.out.println(response.toString()); } |