Loading core/java/android/app/ActivityThread.java +14 −3 Original line number Diff line number Diff line Loading @@ -941,18 +941,19 @@ public final class ActivityThread { @Override public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) { boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) { FileOutputStream fout = new FileOutputStream(fd); PrintWriter pw = new FastPrintWriter(fout); try { dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly); dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly, dumpUnreachable); } finally { pw.flush(); } } private void dumpMemInfo(PrintWriter pw, Debug.MemoryInfo memInfo, boolean checkin, boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly) { boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable) { long nativeMax = Debug.getNativeHeapSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; Loading Loading @@ -1066,6 +1067,16 @@ public final class ActivityThread { pw.println(" Asset Allocations"); pw.print(assetAlloc); } // Unreachable native memory if (dumpUnreachable) { boolean showContents = ((mBoundApplication != null) && ((mBoundApplication.appInfo.flags&ApplicationInfo.FLAG_DEBUGGABLE) != 0)) || android.os.Build.IS_DEBUGGABLE; pw.println(" "); pw.println(" Unreachable memory"); pw.print(Debug.getUnreachableMemory(100, showContents)); } } @Override Loading core/java/android/app/ApplicationThreadNative.java +5 −2 Original line number Diff line number Diff line Loading @@ -534,11 +534,12 @@ public abstract class ApplicationThreadNative extends Binder boolean dumpInfo = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpUnreachable = data.readInt() != 0; String[] args = data.readStringArray(); if (fd != null) { try { dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpDalvik, dumpSummaryOnly, args); dumpDalvik, dumpSummaryOnly, dumpUnreachable, args); } finally { try { fd.close(); Loading Loading @@ -1261,7 +1262,8 @@ class ApplicationThreadProxy implements IApplicationThread { } public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) throws RemoteException { boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); Loading @@ -1271,6 +1273,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpUnreachable ? 1 : 0); data.writeStringArray(args); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); reply.readException(); Loading core/java/android/app/IApplicationThread.java +2 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,8 @@ public interface IApplicationThread extends IInterface { void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) throws RemoteException; boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) throws RemoteException; void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; Loading core/java/android/os/Debug.java +8 −0 Original line number Diff line number Diff line Loading @@ -2111,6 +2111,14 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ public static native void dumpNativeBacktraceToFile(int pid, String file); /** * Get description of unreachable native memory. * @param limit the number of leaks to provide info on, 0 to only get a summary. * @param contents true to include a hex dump of the contents of unreachable memory. * @return the String containing a description of unreachable memory. * @hide */ public static native String getUnreachableMemory(int limit, boolean contents); /** * Return a String describing the calling method and location at a particular stack depth. * @param callStack the Thread stack Loading core/jni/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -253,7 +253,8 @@ LOCAL_SHARED_LIBRARIES := \ libprocessgroup \ libnativebridge \ libradio_metadata \ libnativeloader libnativeloader \ libmemunreachable \ LOCAL_SHARED_LIBRARIES += \ libhwui \ Loading Loading
core/java/android/app/ActivityThread.java +14 −3 Original line number Diff line number Diff line Loading @@ -941,18 +941,19 @@ public final class ActivityThread { @Override public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) { boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) { FileOutputStream fout = new FileOutputStream(fd); PrintWriter pw = new FastPrintWriter(fout); try { dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly); dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly, dumpUnreachable); } finally { pw.flush(); } } private void dumpMemInfo(PrintWriter pw, Debug.MemoryInfo memInfo, boolean checkin, boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly) { boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable) { long nativeMax = Debug.getNativeHeapSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; Loading Loading @@ -1066,6 +1067,16 @@ public final class ActivityThread { pw.println(" Asset Allocations"); pw.print(assetAlloc); } // Unreachable native memory if (dumpUnreachable) { boolean showContents = ((mBoundApplication != null) && ((mBoundApplication.appInfo.flags&ApplicationInfo.FLAG_DEBUGGABLE) != 0)) || android.os.Build.IS_DEBUGGABLE; pw.println(" "); pw.println(" Unreachable memory"); pw.print(Debug.getUnreachableMemory(100, showContents)); } } @Override Loading
core/java/android/app/ApplicationThreadNative.java +5 −2 Original line number Diff line number Diff line Loading @@ -534,11 +534,12 @@ public abstract class ApplicationThreadNative extends Binder boolean dumpInfo = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpUnreachable = data.readInt() != 0; String[] args = data.readStringArray(); if (fd != null) { try { dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpDalvik, dumpSummaryOnly, args); dumpDalvik, dumpSummaryOnly, dumpUnreachable, args); } finally { try { fd.close(); Loading Loading @@ -1261,7 +1262,8 @@ class ApplicationThreadProxy implements IApplicationThread { } public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) throws RemoteException { boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); Loading @@ -1271,6 +1273,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpUnreachable ? 1 : 0); data.writeStringArray(args); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); reply.readException(); Loading
core/java/android/app/IApplicationThread.java +2 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,8 @@ public interface IApplicationThread extends IInterface { void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) throws RemoteException; boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable, String[] args) throws RemoteException; void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; Loading
core/java/android/os/Debug.java +8 −0 Original line number Diff line number Diff line Loading @@ -2111,6 +2111,14 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ public static native void dumpNativeBacktraceToFile(int pid, String file); /** * Get description of unreachable native memory. * @param limit the number of leaks to provide info on, 0 to only get a summary. * @param contents true to include a hex dump of the contents of unreachable memory. * @return the String containing a description of unreachable memory. * @hide */ public static native String getUnreachableMemory(int limit, boolean contents); /** * Return a String describing the calling method and location at a particular stack depth. * @param callStack the Thread stack Loading
core/jni/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -253,7 +253,8 @@ LOCAL_SHARED_LIBRARIES := \ libprocessgroup \ libnativebridge \ libradio_metadata \ libnativeloader libnativeloader \ libmemunreachable \ LOCAL_SHARED_LIBRARIES += \ libhwui \ Loading