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

Commit 9c181ffb authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Improved memory use reporting."

parents 2adf53c7 b437e090
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -14095,6 +14095,7 @@ package android.os {
    method public static long getNativeHeapAllocatedSize();
    method public static long getNativeHeapAllocatedSize();
    method public static long getNativeHeapFreeSize();
    method public static long getNativeHeapFreeSize();
    method public static long getNativeHeapSize();
    method public static long getNativeHeapSize();
    method public static long getPss();
    method public static int getThreadAllocCount();
    method public static int getThreadAllocCount();
    method public static int getThreadAllocSize();
    method public static int getThreadAllocSize();
    method public static deprecated int getThreadExternalAllocCount();
    method public static deprecated int getThreadExternalAllocCount();
+22 −0
Original line number Original line Diff line number Diff line
@@ -1523,6 +1523,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
            return true;
        }
        }


        case GET_PROCESS_PSS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int[] pids = data.createIntArray();
            long[] pss = getProcessPss(pids);
            reply.writeNoException();
            reply.writeLongArray(pss);
            return true;
        }

        }
        }


        return super.onTransact(code, data, reply, flags);
        return super.onTransact(code, data, reply, flags);
@@ -3432,5 +3441,18 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
        reply.recycle();
    }
    }


    public long[] getProcessPss(int[] pids) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeIntArray(pids);
        mRemote.transact(GET_PROCESS_PSS_TRANSACTION, data, reply, 0);
        reply.readException();
        long[] res = reply.createLongArray();
        data.recycle();
        reply.recycle();
        return res;
    }

    private IBinder mRemote;
    private IBinder mRemote;
}
}
+18 −16
Original line number Original line Diff line number Diff line
@@ -729,17 +729,19 @@ public final class ActivityThread {
        }
        }


        @Override
        @Override
        public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, String[] args) {
        public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, boolean checkin,
                boolean all, String[] args) {
            FileOutputStream fout = new FileOutputStream(fd);
            FileOutputStream fout = new FileOutputStream(fd);
            PrintWriter pw = new PrintWriter(fout);
            PrintWriter pw = new PrintWriter(fout);
            try {
            try {
                return dumpMemInfo(pw, args);
                return dumpMemInfo(pw, checkin, all, args);
            } finally {
            } finally {
                pw.flush();
                pw.flush();
            }
            }
        }
        }


        private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, String[] args) {
        private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, boolean checkin, boolean all,
                String[] args) {
            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;
@@ -747,6 +749,10 @@ public final class ActivityThread {
            Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
            Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
            Debug.getMemoryInfo(memInfo);
            Debug.getMemoryInfo(memInfo);


            if (!all) {
                return memInfo;
            }

            Runtime runtime = Runtime.getRuntime();
            Runtime runtime = Runtime.getRuntime();


            long dalvikMax = runtime.totalMemory() / 1024;
            long dalvikMax = runtime.totalMemory() / 1024;
@@ -765,16 +771,8 @@ public final class ActivityThread {
            long sqliteAllocated = SQLiteDebug.getHeapAllocatedSize() / 1024;
            long sqliteAllocated = SQLiteDebug.getHeapAllocatedSize() / 1024;
            SQLiteDebug.PagerStats stats = SQLiteDebug.getDatabaseInfo();
            SQLiteDebug.PagerStats stats = SQLiteDebug.getDatabaseInfo();


            // Check to see if we were called by checkin server. If so, print terse format.
            boolean doCheckinFormat = false;
            if (args != null) {
                for (String arg : args) {
                    if ("-c".equals(arg)) doCheckinFormat = true;
                }
            }

            // For checkin, we print one long comma-separated list of values
            // For checkin, we print one long comma-separated list of values
            if (doCheckinFormat) {
            if (checkin) {
                // NOTE: if you change anything significant below, also consider changing
                // NOTE: if you change anything significant below, also consider changing
                // ACTIVITY_THREAD_CHECKIN_VERSION.
                // ACTIVITY_THREAD_CHECKIN_VERSION.
                String processName = (mBoundApplication != null)
                String processName = (mBoundApplication != null)
@@ -841,13 +839,17 @@ public final class ActivityThread {
                pw.print(sqliteAllocated); pw.print(',');
                pw.print(sqliteAllocated); pw.print(',');
                pw.print(stats.memoryUsed / 1024); pw.print(',');
                pw.print(stats.memoryUsed / 1024); pw.print(',');
                pw.print(stats.pageCacheOverflo / 1024); pw.print(',');
                pw.print(stats.pageCacheOverflo / 1024); pw.print(',');
                pw.print(stats.largestMemAlloc / 1024); pw.print(',');
                pw.print(stats.largestMemAlloc / 1024);
                for (int i = 0; i < stats.dbStats.size(); i++) {
                for (int i = 0; i < stats.dbStats.size(); i++) {
                    DbStats dbStats = stats.dbStats.get(i);
                    DbStats dbStats = stats.dbStats.get(i);
                    printRow(pw, DB_INFO_FORMAT, dbStats.pageSize, dbStats.dbSize,
                    pw.print(','); pw.print(dbStats.dbName);
                            dbStats.lookaside, dbStats.cache, dbStats.dbName);
                    pw.print(','); pw.print(dbStats.pageSize);
                    pw.print(',');
                    pw.print(','); pw.print(dbStats.dbSize);
                }
                    pw.print(','); pw.print(dbStats.lookaside);
                    pw.print(','); pw.print(dbStats.cache);
                    pw.print(','); pw.print(dbStats.cache);
                }
                pw.println();


                return memInfo;
                return memInfo;
            }
            }
+7 −2
Original line number Original line Diff line number Diff line
@@ -491,11 +491,13 @@ public abstract class ApplicationThreadNative extends Binder
        {
        {
            data.enforceInterface(IApplicationThread.descriptor);
            data.enforceInterface(IApplicationThread.descriptor);
            ParcelFileDescriptor fd = data.readFileDescriptor();
            ParcelFileDescriptor fd = data.readFileDescriptor();
            boolean checkin = data.readInt() != 0;
            boolean all = data.readInt() != 0;
            String[] args = data.readStringArray();
            String[] args = data.readStringArray();
            Debug.MemoryInfo mi = null;
            Debug.MemoryInfo mi = null;
            if (fd != null) {
            if (fd != null) {
                try {
                try {
                    mi = dumpMemInfo(fd.getFileDescriptor(), args);
                    mi = dumpMemInfo(fd.getFileDescriptor(), checkin, all, args);
                } finally {
                } finally {
                    try {
                    try {
                        fd.close();
                        fd.close();
@@ -1049,11 +1051,14 @@ class ApplicationThreadProxy implements IApplicationThread {
                IBinder.FLAG_ONEWAY);
                IBinder.FLAG_ONEWAY);
    }
    }


    public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, String[] args) throws RemoteException {
    public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, boolean checkin, boolean all,
            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);
        data.writeFileDescriptor(fd);
        data.writeFileDescriptor(fd);
        data.writeInt(checkin ? 1 : 0);
        data.writeInt(all ? 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();
+4 −1
Original line number Original line Diff line number Diff line
@@ -365,6 +365,8 @@ public interface IActivityManager extends IInterface {


    public void updatePersistentConfiguration(Configuration values) throws RemoteException;
    public void updatePersistentConfiguration(Configuration values) throws RemoteException;


    public long[] getProcessPss(int[] pids) throws RemoteException;

    /*
    /*
     * Private non-Binder interfaces
     * Private non-Binder interfaces
     */
     */
@@ -593,4 +595,5 @@ public interface IActivityManager extends IInterface {
    int UNREGISTER_PROCESS_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+133;
    int UNREGISTER_PROCESS_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+133;
    int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134;
    int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134;
    int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
    int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
    int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
}
}
Loading