diff options
| author | 2018-11-22 09:35:30 +0000 | |
|---|---|---|
| committer | 2018-11-22 09:35:30 +0000 | |
| commit | 9fa0710c665f560b71b855a2e34c04c55840d86d (patch) | |
| tree | 3842b36b68bf63a179924b11bd2fd3a80000d3da | |
| parent | f58e10d979eb897f25a73fb0da468675eac90f89 (diff) | |
| parent | d70e20218ae3a189c72e179e5f7ec7faa918a1c5 (diff) | |
Merge "Fix vmalloc memory usage parsing."
| -rw-r--r-- | core/jni/android_os_Debug.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index ccbe0ee65269..49d500754290 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -692,14 +692,8 @@ static jlong android_os_Debug_getPss(JNIEnv *env, jobject clazz) static long get_allocated_vmalloc_memory() { char line[1024]; - // Ignored tags that don't actually consume memory (ie remappings) - static const char* const ignored_tags[] = { - "ioremap", - "map_lowmem", - "vm_map_ram", - NULL - }; - long size, vmalloc_allocated_size = 0; + + long vmalloc_allocated_size = 0; UniqueFile fp = MakeUniqueFile("/proc/vmallocinfo", "re"); if (fp == nullptr) { @@ -710,17 +704,15 @@ static long get_allocated_vmalloc_memory() { if (fgets(line, 1024, fp.get()) == NULL) { break; } - bool valid_line = true; - int i = 0; - while (ignored_tags[i]) { - if (strstr(line, ignored_tags[i]) != NULL) { - valid_line = false; - break; - } - i++; + + // check to see if there are pages mapped in vmalloc area + if (!strstr(line, "pages=")) { + continue; } - if (valid_line && (sscanf(line, "%*x-%*x %ld", &size) == 1)) { - vmalloc_allocated_size += size; + + long nr_pages; + if (sscanf(line, "%*x-%*x %*ld %*s pages=%ld", &nr_pages) == 1) { + vmalloc_allocated_size += (nr_pages * getpagesize()); } } return vmalloc_allocated_size; |