Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd45c084 authored by Colin Cross's avatar Colin Cross Committed by android-build-merger
Browse files

Merge "Add dumpsys meminfo --unreachable"

am: 916ea081

* commit '916ea081':
  Add dumpsys meminfo --unreachable
parents 0a2f80ba 916ea081
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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
+5 −2
Original line number Diff line number Diff line
@@ -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();
@@ -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);
@@ -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();
+2 −1
Original line number Diff line number Diff line
@@ -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;
+8 −0
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -253,7 +253,8 @@ LOCAL_SHARED_LIBRARIES := \
    libprocessgroup \
    libnativebridge \
    libradio_metadata \
    libnativeloader
    libnativeloader \
    libmemunreachable \

LOCAL_SHARED_LIBRARIES += \
    libhwui \
Loading