Merge "Make LoadClass collect garbage as promised" am: e16473b1da am: 87376c8b47 am: 3d794a3a66

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2150615

Change-Id: Ic1ceed65d45931640ee4c4c33d726dbc1db09290
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hans Boehm
2022-10-07 01:20:03 +00:00
committed by Automerger Merge Worker

View File

@@ -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());
}