diff options
author | Richard Uhler <ruhler@google.com> | 2015-06-09 16:40:54 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-09 16:40:57 +0000 |
commit | 659716d7a03553006e67b01008c2e9e03a20ed31 (patch) | |
tree | 77647b8aa1fab702d305d89df1a355bd3d0d37e3 | |
parent | 058652c23d9551e780e56d26d9e6c46963bfafee (diff) | |
parent | 350e6dc985d118dd004fca60276e3766eb86d073 (diff) | |
download | frameworks_base-659716d7a03553006e67b01008c2e9e03a20ed31.zip frameworks_base-659716d7a03553006e67b01008c2e9e03a20ed31.tar.gz frameworks_base-659716d7a03553006e67b01008c2e9e03a20ed31.tar.bz2 |
Merge "Add Debug.MemoryInfo.getMemoryStats API." into mnc-dev
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | api/system-current.txt | 2 | ||||
-rw-r--r-- | core/java/android/os/Debug.java | 127 |
3 files changed, 131 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 0214001..58ecc39 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22899,6 +22899,8 @@ package android.os { public static class Debug.MemoryInfo implements android.os.Parcelable { ctor public Debug.MemoryInfo(); method public int describeContents(); + method public java.lang.String getMemoryStat(java.lang.String); + method public java.util.Map<java.lang.String, java.lang.String> getMemoryStats(); method public int getTotalPrivateClean(); method public int getTotalPrivateDirty(); method public int getTotalPss(); diff --git a/api/system-current.txt b/api/system-current.txt index dc1e1fb..e3e1787 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -24817,6 +24817,8 @@ package android.os { public static class Debug.MemoryInfo implements android.os.Parcelable { ctor public Debug.MemoryInfo(); method public int describeContents(); + method public java.lang.String getMemoryStat(java.lang.String); + method public java.util.Map<java.lang.String, java.lang.String> getMemoryStats(); method public int getTotalPrivateClean(); method public int getTotalPrivateDirty(); method public int getTotalPss(); diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 19c8fa9..87e8c5e 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -34,6 +34,7 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.HashMap; import java.util.Map; import org.apache.harmony.dalvik.ddmc.Chunk; @@ -389,6 +390,132 @@ public final class Debug } } + /** + * Returns the value of a particular memory statistic or {@code null} if no + * such memory statistic exists. + * + * <p>The following table lists the memory statistics that are supported. + * Note that memory statistics may be added or removed in a future API level.</p> + * + * <table> + * <thead> + * <tr> + * <th>Memory statistic name</th> + * <th>Meaning</th> + * <th>Example</th> + * <th>Supported (API Levels)</th> + * </tr> + * </thead> + * <tbody> + * <tr> + * <td>summary.java-heap</td> + * <td>The private Java Heap usage in kB. This corresponds to the Java Heap field + * in the App Summary section output by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.native-heap</td> + * <td>The private Native Heap usage in kB. This corresponds to the Native Heap + * field in the App Summary section output by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.code</td> + * <td>The memory usage for static code and resources in kB. This corresponds to + * the Code field in the App Summary section output by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.stack</td> + * <td>The stack usage in kB. This corresponds to the Stack field in the + * App Summary section output by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.graphics</td> + * <td>The graphics usage in kB. This corresponds to the Graphics field in the + * App Summary section output by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.private-other</td> + * <td>Other private memory usage in kB. This corresponds to the Private Other + * field output in the App Summary section by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.system</td> + * <td>Shared and system memory usage in kB. This corresponds to the System + * field output in the App Summary section by dumpsys meminfo.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.total-pss</td> + * <td>Total PPS memory usage in kB.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>summary.total-swap</td> + * <td>Total swap usage in kB.</td> + * <td>{@code 1442}</td> + * <td>23</td> + * </tr> + * </tbody> + * </table> + */ + public String getMemoryStat(String statName) { + switch(statName) { + case "summary.java-heap": + return Integer.toString(getSummaryJavaHeap()); + case "summary.native-heap": + return Integer.toString(getSummaryNativeHeap()); + case "summary.code": + return Integer.toString(getSummaryCode()); + case "summary.stack": + return Integer.toString(getSummaryStack()); + case "summary.graphics": + return Integer.toString(getSummaryGraphics()); + case "summary.private-other": + return Integer.toString(getSummaryPrivateOther()); + case "summary.system": + return Integer.toString(getSummarySystem()); + case "summary.total-pss": + return Integer.toString(getSummaryTotalPss()); + case "summary.total-swap": + return Integer.toString(getSummaryTotalSwap()); + default: + return null; + } + } + + /** + * Returns a map of the names/values of the memory statistics + * that {@link #getMemoryStat(String)} supports. + * + * @return a map of the names/values of the supported memory statistics. + */ + public Map<String, String> getMemoryStats() { + Map<String, String> stats = new HashMap<String, String>(); + stats.put("summary.java-heap", Integer.toString(getSummaryJavaHeap())); + stats.put("summary.native-heap", Integer.toString(getSummaryNativeHeap())); + stats.put("summary.code", Integer.toString(getSummaryCode())); + stats.put("summary.stack", Integer.toString(getSummaryStack())); + stats.put("summary.graphics", Integer.toString(getSummaryGraphics())); + stats.put("summary.private-other", Integer.toString(getSummaryPrivateOther())); + stats.put("summary.system", Integer.toString(getSummarySystem())); + stats.put("summary.total-pss", Integer.toString(getSummaryTotalPss())); + stats.put("summary.total-swap", Integer.toString(getSummaryTotalSwap())); + return stats; + } + /** * Pss of Java Heap bytes in KB due to the application. * Notes: |