From 8e69257a9c7e9c1781e1f53d8856358ada38921d Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 10 Sep 2013 19:06:15 -0700 Subject: Implement #10749688: Improve low memory reporting This significantly reworks the logging we do when all cached processes are killed: - We now collect the list of processes in-place so we have a snapshot of exactly when the low memory situation happened. - In that snapshot we include the key process state: oom adj, proc state, adj reasons. - The report then asynchronously collects pss information for those processes. - The ultimate data printed to the log looks like a mix between the "dumpsys meminfo" and "dumpsys activity" output. This code no longer uses "dumpsys meminfo" itself, so some of that data is no longer included, in particular pss organized by allocation type. In doing this, I realized that the existing code that is supposed to run "procstats" is not currently working. And at that point I realized, really, when we are collecting this pss data we'd really like to include all those native processes using ghod-only-knows how much RAM. And guess what, we have a list of processes available in ProcessCpuTracker. So we now also collect and print information for native processes, and we also do this for "dumpsys meminfo" which really seems like a good thing when we are printing summaries of all pss and such. I also improved the code for reading /proc/meminfo to be able to load all the interesting fields from there, and am now printing that as well. Change-Id: I9e7d13e9c07a8249c7a7e12e5433973b2c0fdc11 --- core/java/android/os/Debug.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'core/java/android/os') diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 8f68fc1..eb91238 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -1018,6 +1018,28 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ public static native long getPss(int pid, long[] outUss); + /** @hide */ + public static final int MEMINFO_TOTAL = 0; + /** @hide */ + public static final int MEMINFO_FREE = 1; + /** @hide */ + public static final int MEMINFO_BUFFERS = 2; + /** @hide */ + public static final int MEMINFO_CACHED = 3; + /** @hide */ + public static final int MEMINFO_SHMEM = 4; + /** @hide */ + public static final int MEMINFO_SLAB = 5; + /** @hide */ + public static final int MEMINFO_COUNT = 6; + + /** + * Retrieves /proc/meminfo. outSizes is filled with fields + * as defined by MEMINFO_* offsets. + * @hide + */ + public static native void getMemInfo(long[] outSizes); + /** * Establish an object allocation limit in the current thread. * This feature was never enabled in release builds. The -- cgit v1.1