Loading tests/AppMemoryTest/app/AndroidManifest.xml +5 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <application android:debuggable="true" > <!-- debuggable="true" is required to be able to generate a heap profile. --> <!-- testOnly="true" is required to be able to access "@hide" APIs such as VMDebug. --> <application android:debuggable="true" android:testOnly="true"> <activity android:name=".EmptyActivity" android:label="_EmptyActivity" android:enabled="true" Loading tests/AppMemoryTest/app/src/android/app/memory/tests/helper/EmptyActivity.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import android.os.Debug; import android.os.SystemClock; import android.util.Log; import dalvik.system.VMDebug; import org.apache.harmony.dalvik.ddmc.DdmVmInternal; import java.io.File; Loading @@ -45,7 +43,6 @@ public class EmptyActivity extends Activity { // Configure for a heap dump private static void configureForHeap() { VMDebug.setAllocTrackerStackDepth(64); DdmVmInternal.setRecentAllocationsTrackingEnabled(true); } Loading Loading @@ -96,7 +93,7 @@ public class EmptyActivity extends Activity { } } final String allocated = VMDebug.getRuntimeStat("art.gc.bytes-allocated"); final long allocated = android.os.Debug.getGlobalAllocSize(); try { Debug.dumpHprofData(dumpPath + ".hprof"); Loading @@ -114,7 +111,7 @@ public class EmptyActivity extends Activity { // report generators to sequence statistics files from multiple runs on the same // build. out.format("memory.testhelper.runtime %d\n", System.currentTimeMillis() / 1000); out.format("art.gc.bytes-allocated %s\n", allocated); out.format("art.gc.bytes-allocated %d\n", allocated); out.format("extra-size.length %d\n", (mExtraBytes != null) ? mExtraBytes.length : 0); out.format("sentinel.string %s\n", mSentinelString); } catch (FileNotFoundException e) { Loading tests/AppMemoryTest/src/android/app/memory/tests/AppMemoryTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ public class AppMemoryTest { try (var result = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) { byte[] response = new byte[100]; int len = result.read(response); if (len <= 0) { return ""; } return new String(response, 0, len); } catch (IOException e) { // Ignore the exception. Loading @@ -88,6 +91,7 @@ public class AppMemoryTest { @Before public void setUp() { runShellCommandWithResult("setprop debug.allocTracker.stackDepth 64"); final String apk = mRootPath + HELPER_APK; File apkFile = new File(apk); assertTrue("apk not found", apkFile.exists()); Loading @@ -99,6 +103,7 @@ public class AppMemoryTest { @After public void tearDown() { runShellCommandWithResult("setprop debug.allocTracker.stackDepth 16"); uninstallHelper(); } Loading Loading
tests/AppMemoryTest/app/AndroidManifest.xml +5 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <application android:debuggable="true" > <!-- debuggable="true" is required to be able to generate a heap profile. --> <!-- testOnly="true" is required to be able to access "@hide" APIs such as VMDebug. --> <application android:debuggable="true" android:testOnly="true"> <activity android:name=".EmptyActivity" android:label="_EmptyActivity" android:enabled="true" Loading
tests/AppMemoryTest/app/src/android/app/memory/tests/helper/EmptyActivity.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import android.os.Debug; import android.os.SystemClock; import android.util.Log; import dalvik.system.VMDebug; import org.apache.harmony.dalvik.ddmc.DdmVmInternal; import java.io.File; Loading @@ -45,7 +43,6 @@ public class EmptyActivity extends Activity { // Configure for a heap dump private static void configureForHeap() { VMDebug.setAllocTrackerStackDepth(64); DdmVmInternal.setRecentAllocationsTrackingEnabled(true); } Loading Loading @@ -96,7 +93,7 @@ public class EmptyActivity extends Activity { } } final String allocated = VMDebug.getRuntimeStat("art.gc.bytes-allocated"); final long allocated = android.os.Debug.getGlobalAllocSize(); try { Debug.dumpHprofData(dumpPath + ".hprof"); Loading @@ -114,7 +111,7 @@ public class EmptyActivity extends Activity { // report generators to sequence statistics files from multiple runs on the same // build. out.format("memory.testhelper.runtime %d\n", System.currentTimeMillis() / 1000); out.format("art.gc.bytes-allocated %s\n", allocated); out.format("art.gc.bytes-allocated %d\n", allocated); out.format("extra-size.length %d\n", (mExtraBytes != null) ? mExtraBytes.length : 0); out.format("sentinel.string %s\n", mSentinelString); } catch (FileNotFoundException e) { Loading
tests/AppMemoryTest/src/android/app/memory/tests/AppMemoryTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ public class AppMemoryTest { try (var result = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) { byte[] response = new byte[100]; int len = result.read(response); if (len <= 0) { return ""; } return new String(response, 0, len); } catch (IOException e) { // Ignore the exception. Loading @@ -88,6 +91,7 @@ public class AppMemoryTest { @Before public void setUp() { runShellCommandWithResult("setprop debug.allocTracker.stackDepth 64"); final String apk = mRootPath + HELPER_APK; File apkFile = new File(apk); assertTrue("apk not found", apkFile.exists()); Loading @@ -99,6 +103,7 @@ public class AppMemoryTest { @After public void tearDown() { runShellCommandWithResult("setprop debug.allocTracker.stackDepth 16"); uninstallHelper(); } Loading