diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-11-05 07:32:29 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-11-05 07:32:29 +0000 |
commit | 0dbb4f8155df7852810e257de767b1f701f2fe3c (patch) | |
tree | 14f081e1619ce8a3008b18820d394ec69651a526 | |
parent | 230b99fb850bbbe17b8ee41d1968062d72895fdd (diff) | |
parent | 8be30e05a19e861a4605149e266e9b3e73542d1b (diff) | |
download | extras-android-4.0.3_r1.tar.gz |
am 8be30e05: Merge "Include the shared memory and slab memory in procrank output." into ics-mr0android-sdk-4.0.3_r1android-sdk-4.0.3-tools_r1android-cts-verifier-4.0_r1android-cts-verifier-4.0.3_r1android-cts-4.0.3_r1android-4.0.3_r1.1android-4.0.3_r1
* commit '8be30e05a19e861a4605149e266e9b3e73542d1b':
Include the shared memory and slab memory in procrank output.
-rw-r--r-- | procrank/procrank.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/procrank/procrank.c b/procrank/procrank.c index b601b408..28d6f251 100644 --- a/procrank/procrank.c +++ b/procrank/procrank.c @@ -46,7 +46,7 @@ int (*compfn)(const void *a, const void *b); static int order; void print_mem_info() { - char buffer[256]; + char buffer[1024]; int numFound = 0; int fd = open("/proc/meminfo", O_RDONLY); @@ -70,6 +70,8 @@ void print_mem_info() { "MemFree:", "Buffers:", "Cached:", + "Shmem:", + "Slab:", NULL }; static const int tagsLen[] = { @@ -77,12 +79,14 @@ void print_mem_info() { 8, 8, 7, + 6, + 5, 0 }; - long mem[] = { 0, 0, 0, 0 }; + long mem[] = { 0, 0, 0, 0, 0, 0 }; char* p = buffer; - while (*p && numFound < 4) { + while (*p && numFound < 6) { int i = 0; while (tags[i]) { if (strncmp(p, tags[i], tagsLen[i]) == 0) { @@ -93,7 +97,6 @@ void print_mem_info() { if (*p != 0) { *p = 0; p++; - if (*p == 0) p--; } mem[i] = atoll(num); numFound++; @@ -101,11 +104,14 @@ void print_mem_info() { } i++; } - p++; + while (*p && *p != '\n') { + p++; + } + if (*p) p++; } - printf("RAM: %ldK total, %ldK free, %ldK buffers, %ldK cached\n", - mem[0], mem[1], mem[2], mem[3]); + printf("RAM: %ldK total, %ldK free, %ldK buffers, %ldK cached, %ldK shmem, %ldK slab\n", + mem[0], mem[1], mem[2], mem[3], mem[4], mem[5]); } int main(int argc, char *argv[]) { |