summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-11-05 00:31:02 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-05 00:31:02 -0700
commit8be30e05a19e861a4605149e266e9b3e73542d1b (patch)
tree14f081e1619ce8a3008b18820d394ec69651a526
parent2c9d3f9293fc4c511e8f031cdade3f0cb9d93127 (diff)
parent83b0b0a57a0c20984e207e4d6987faeba736140c (diff)
downloadextras-ics-mr0-release.tar.gz
Merge "Include the shared memory and slab memory in procrank output." into ics-mr0android-sdk-adt_r16.0.1android-cts-4.0_r1android-4.0.2_r1ics-mr0-releaseics-mr0
-rw-r--r--procrank/procrank.c20
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[]) {