diff options
| author | Dianne Hackborn <hackbod@google.com> | 2013-09-24 23:10:14 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2013-09-25 15:45:56 -0700 |
| commit | cbd9a52f256087426feb19ac6e51eff772e81375 (patch) | |
| tree | 87c36b8305dc16b0a34b3c1bf66eea05034f4422 /core/jni | |
| parent | 044fd573ce58142309f9fc503cf5d52af447d082 (diff) | |
| download | frameworks_base-cbd9a52f256087426feb19ac6e51eff772e81375.zip frameworks_base-cbd9a52f256087426feb19ac6e51eff772e81375.tar.gz frameworks_base-cbd9a52f256087426feb19ac6e51eff772e81375.tar.bz2 | |
Fix issue #10903002: com.facebook.katana keeps itself in A Services
Now when memory low, if a service's process is above
a selected pss, then the process is not allowed to go
in to the service a list.
Also simplified the normal meminfo details dump to not
include the shared dirty and shared clean sizes by
default, since these can be very confusing. You will
still get to see them with the "-a" flag.
Finally some small steps to better managing service
processes in the LRU list, so hopefully we can some
day be better about letting them drop down in the list
when there isn't really much interesting happening in
the process. Not yet used at this point.
Change-Id: I654bfd6d05de2a63120185ebb15ffda8cbeb5dac
Diffstat (limited to 'core/jni')
| -rw-r--r-- | core/jni/android_os_Debug.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index 60540f4..aa5b254 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -516,6 +516,19 @@ static jlong android_os_Debug_getPss(JNIEnv *env, jobject clazz) return android_os_Debug_getPssPid(env, clazz, getpid(), NULL); } +enum { + MEMINFO_TOTAL, + MEMINFO_FREE, + MEMINFO_BUFFERS, + MEMINFO_CACHED, + MEMINFO_SHMEM, + MEMINFO_SLAB, + MEMINFO_SWAP_TOTAL, + MEMINFO_SWAP_FREE, + MEMINFO_ZRAM_TOTAL, + MEMINFO_COUNT +}; + static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray out) { char buffer[1024]; @@ -529,15 +542,15 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o int fd = open("/proc/meminfo", O_RDONLY); if (fd < 0) { - printf("Unable to open /proc/meminfo: %s\n", strerror(errno)); + ALOGW("Unable to open /proc/meminfo: %s\n", strerror(errno)); return; } - const int len = read(fd, buffer, sizeof(buffer)-1); + int len = read(fd, buffer, sizeof(buffer)-1); close(fd); if (len < 0) { - printf("Empty /proc/meminfo"); + ALOGW("Empty /proc/meminfo"); return; } buffer[len] = 0; @@ -549,6 +562,8 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o "Cached:", "Shmem:", "Slab:", + "SwapTotal:", + "SwapFree:", NULL }; static const int tagsLen[] = { @@ -558,12 +573,14 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o 7, 6, 5, + 10, + 9, 0 }; - long mem[] = { 0, 0, 0, 0, 0, 0 }; + long mem[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char* p = buffer; - while (*p && numFound < 6) { + while (*p && numFound < 8) { int i = 0; while (tags[i]) { if (strncmp(p, tags[i], tagsLen[i]) == 0) { @@ -587,7 +604,20 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o if (*p) p++; } + fd = open("/sys/block/zram0/mem_used_total", O_RDONLY); + if (fd >= 0) { + len = read(fd, buffer, sizeof(buffer)-1); + close(fd); + if (len > 0) { + buffer[len] = 0; + mem[MEMINFO_ZRAM_TOTAL] = atoll(buffer); + } + } + int maxNum = env->GetArrayLength(out); + if (maxNum > MEMINFO_COUNT) { + maxNum = MEMINFO_COUNT; + } jlong* outArray = env->GetLongArrayElements(out, 0); if (outArray != NULL) { for (int i=0; i<maxNum && tags[i]; i++) { |
