Loading core/java/android/app/ActivityThread.java +14 −3 Original line number Original line Diff line number Diff line Loading @@ -977,18 +977,19 @@ public final class ActivityThread { @Override @Override public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, 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); FileOutputStream fout = new FileOutputStream(fd); PrintWriter pw = new FastPrintWriter(fout); PrintWriter pw = new FastPrintWriter(fout); try { try { dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly); dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly, dumpUnreachable); } finally { } finally { pw.flush(); pw.flush(); } } } } private void dumpMemInfo(PrintWriter pw, Debug.MemoryInfo memInfo, boolean checkin, 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 nativeMax = Debug.getNativeHeapSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; Loading Loading @@ -1102,6 +1103,16 @@ public final class ActivityThread { pw.println(" Asset Allocations"); pw.println(" Asset Allocations"); pw.print(assetAlloc); 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 @Override Loading core/java/android/app/ApplicationThreadNative.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -548,11 +548,12 @@ public abstract class ApplicationThreadNative extends Binder boolean dumpInfo = data.readInt() != 0; boolean dumpInfo = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpUnreachable = data.readInt() != 0; String[] args = data.readStringArray(); String[] args = data.readStringArray(); if (fd != null) { if (fd != null) { try { try { dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpDalvik, dumpSummaryOnly, args); dumpDalvik, dumpSummaryOnly, dumpUnreachable, args); } finally { } finally { try { try { fd.close(); fd.close(); Loading Loading @@ -1328,7 +1329,8 @@ class ApplicationThreadProxy implements IApplicationThread { } } public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, 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 data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeInterfaceToken(IApplicationThread.descriptor); Loading @@ -1338,6 +1340,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpUnreachable ? 1 : 0); data.writeStringArray(args); data.writeStringArray(args); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); reply.readException(); reply.readException(); Loading core/java/android/app/IApplicationThread.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -133,7 +133,8 @@ public interface IApplicationThread extends IInterface { void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, 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 dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; Loading core/java/android/os/Debug.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -2157,6 +2157,14 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ */ public static native void dumpNativeBacktraceToFile(int pid, String file); 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. * Return a String describing the calling method and location at a particular stack depth. * @param callStack the Thread stack * @param callStack the Thread stack Loading core/jni/Android.mk +2 −1 Original line number Original line Diff line number Diff line Loading @@ -260,7 +260,8 @@ LOCAL_SHARED_LIBRARIES := \ libprocessgroup \ libprocessgroup \ libnativebridge \ libnativebridge \ libradio_metadata \ libradio_metadata \ libnativeloader libnativeloader \ libmemunreachable \ LOCAL_SHARED_LIBRARIES += \ LOCAL_SHARED_LIBRARIES += \ libhwui \ libhwui \ Loading Loading
core/java/android/app/ActivityThread.java +14 −3 Original line number Original line Diff line number Diff line Loading @@ -977,18 +977,19 @@ public final class ActivityThread { @Override @Override public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, 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); FileOutputStream fout = new FileOutputStream(fd); PrintWriter pw = new FastPrintWriter(fout); PrintWriter pw = new FastPrintWriter(fout); try { try { dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly); dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly, dumpUnreachable); } finally { } finally { pw.flush(); pw.flush(); } } } } private void dumpMemInfo(PrintWriter pw, Debug.MemoryInfo memInfo, boolean checkin, 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 nativeMax = Debug.getNativeHeapSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; long nativeFree = Debug.getNativeHeapFreeSize() / 1024; Loading Loading @@ -1102,6 +1103,16 @@ public final class ActivityThread { pw.println(" Asset Allocations"); pw.println(" Asset Allocations"); pw.print(assetAlloc); 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 @Override Loading
core/java/android/app/ApplicationThreadNative.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -548,11 +548,12 @@ public abstract class ApplicationThreadNative extends Binder boolean dumpInfo = data.readInt() != 0; boolean dumpInfo = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpDalvik = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpSummaryOnly = data.readInt() != 0; boolean dumpUnreachable = data.readInt() != 0; String[] args = data.readStringArray(); String[] args = data.readStringArray(); if (fd != null) { if (fd != null) { try { try { dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo, dumpDalvik, dumpSummaryOnly, args); dumpDalvik, dumpSummaryOnly, dumpUnreachable, args); } finally { } finally { try { try { fd.close(); fd.close(); Loading Loading @@ -1328,7 +1329,8 @@ class ApplicationThreadProxy implements IApplicationThread { } } public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, 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 data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeInterfaceToken(IApplicationThread.descriptor); Loading @@ -1338,6 +1340,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpInfo ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpDalvik ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpSummaryOnly ? 1 : 0); data.writeInt(dumpUnreachable ? 1 : 0); data.writeStringArray(args); data.writeStringArray(args); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0); reply.readException(); reply.readException(); Loading
core/java/android/app/IApplicationThread.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -133,7 +133,8 @@ public interface IApplicationThread extends IInterface { void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void scheduleTrimMemory(int level) throws RemoteException; void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo, 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 dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; void unstableProviderDied(IBinder provider) throws RemoteException; Loading
core/java/android/os/Debug.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -2157,6 +2157,14 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ */ public static native void dumpNativeBacktraceToFile(int pid, String file); 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. * Return a String describing the calling method and location at a particular stack depth. * @param callStack the Thread stack * @param callStack the Thread stack Loading
core/jni/Android.mk +2 −1 Original line number Original line Diff line number Diff line Loading @@ -260,7 +260,8 @@ LOCAL_SHARED_LIBRARIES := \ libprocessgroup \ libprocessgroup \ libnativebridge \ libnativebridge \ libradio_metadata \ libradio_metadata \ libnativeloader libnativeloader \ libmemunreachable \ LOCAL_SHARED_LIBRARIES += \ LOCAL_SHARED_LIBRARIES += \ libhwui \ libhwui \ Loading