Loading core/java/android/os/Debug.java +7 −6 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public final class Debug public int otherSharedClean; /** @hide */ public static final int NUM_OTHER_STATS = 13; public static final int NUM_OTHER_STATS = 14; /** @hide */ public static final int NUM_DVK_STATS = 5; Loading Loading @@ -285,11 +285,12 @@ public final class Debug case 10: return "code mmap"; case 11: return "image mmap"; case 12: return "Other mmap"; case 13: return ".Heap"; case 14: return ".LOS"; case 15: return ".LinearAlloc"; case 16: return ".GC"; case 17: return ".JITCache"; case 13: return "GPU"; case 14: return ".Heap"; case 15: return ".LOS"; case 16: return ".LinearAlloc"; case 17: return ".GC"; case 18: return ".JITCache"; default: return "????"; } } Loading core/jni/android_os_Debug.cpp +95 −21 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ enum { HEAP_OAT, HEAP_ART, HEAP_UNKNOWN_MAP, HEAP_GPU, HEAP_DALVIK_NORMAL, HEAP_DALVIK_LARGE, Loading @@ -64,7 +65,7 @@ enum { HEAP_DALVIK_CODE_CACHE, _NUM_HEAP, _NUM_EXCLUSIVE_HEAP = HEAP_UNKNOWN_MAP+1, _NUM_EXCLUSIVE_HEAP = HEAP_GPU+1, _NUM_CORE_HEAP = HEAP_NATIVE+1 }; Loading Loading @@ -137,6 +138,72 @@ static jlong android_os_Debug_getNativeHeapFreeSize(JNIEnv *env, jobject clazz) #endif } // XXX Qualcom-specific! static jlong read_gpu_mem(int pid) { char line[1024]; jlong uss = 0; unsigned temp; char tmp[128]; FILE *fp; sprintf(tmp, "/d/kgsl/proc/%d/mem", pid); fp = fopen(tmp, "r"); if (fp == 0) { //ALOGI("Unable to open: %s", tmp); return 0; } while (true) { if (fgets(line, 1024, fp) == NULL) { break; } //ALOGI("Read: %s", line); // Format is: // gpuaddr useraddr size id flags type usage sglen // 54676000 54676000 4096 1 ----p gpumem arraybuffer 1 // // If useraddr is 0, this is gpu mem not otherwise accounted // against the process. // Make sure line is long enough. int i = 0; while (i < 9) { if (line[i] == 0) { break; } i++; } if (i < 9) { //ALOGI("Early line term!"); continue; } // Look to see if useraddr is 00000000. while (i < 17) { if (line[i] != '0') { break; } i++; } if (i < 17) { //ALOGI("useraddr not 0!"); continue; } uss += atoi(line + i); //ALOGI("Uss now: %ld", uss); } fclose(fp); // Convert from bytes to KB. return uss / 1024; } static void read_mapinfo(FILE *fp, stats_t* stats) { char line[1024]; Loading Loading @@ -340,6 +407,10 @@ static void android_os_Debug_getDirtyPagesPid(JNIEnv *env, jobject clazz, load_maps(pid, stats); jlong gpu = read_gpu_mem(pid); stats[HEAP_GPU].pss += gpu; stats[HEAP_GPU].privateDirty += gpu; for (int i=_NUM_CORE_HEAP; i<_NUM_EXCLUSIVE_HEAP; i++) { stats[HEAP_UNKNOWN].pss += stats[i].pss; stats[HEAP_UNKNOWN].swappablePss += stats[i].swappablePss; Loading Loading @@ -394,10 +465,12 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid, jl char tmp[128]; FILE *fp; pss = uss = read_gpu_mem(pid); sprintf(tmp, "/proc/%d/smaps", pid); fp = fopen(tmp, "r"); if (fp == 0) return 0; if (fp != 0) { while (true) { if (fgets(line, 1024, fp) == NULL) { break; Loading @@ -422,6 +495,7 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid, jl } fclose(fp); } if (outUss != NULL) { if (env->GetArrayLength(outUss) >= 1) { Loading Loading
core/java/android/os/Debug.java +7 −6 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public final class Debug public int otherSharedClean; /** @hide */ public static final int NUM_OTHER_STATS = 13; public static final int NUM_OTHER_STATS = 14; /** @hide */ public static final int NUM_DVK_STATS = 5; Loading Loading @@ -285,11 +285,12 @@ public final class Debug case 10: return "code mmap"; case 11: return "image mmap"; case 12: return "Other mmap"; case 13: return ".Heap"; case 14: return ".LOS"; case 15: return ".LinearAlloc"; case 16: return ".GC"; case 17: return ".JITCache"; case 13: return "GPU"; case 14: return ".Heap"; case 15: return ".LOS"; case 16: return ".LinearAlloc"; case 17: return ".GC"; case 18: return ".JITCache"; default: return "????"; } } Loading
core/jni/android_os_Debug.cpp +95 −21 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ enum { HEAP_OAT, HEAP_ART, HEAP_UNKNOWN_MAP, HEAP_GPU, HEAP_DALVIK_NORMAL, HEAP_DALVIK_LARGE, Loading @@ -64,7 +65,7 @@ enum { HEAP_DALVIK_CODE_CACHE, _NUM_HEAP, _NUM_EXCLUSIVE_HEAP = HEAP_UNKNOWN_MAP+1, _NUM_EXCLUSIVE_HEAP = HEAP_GPU+1, _NUM_CORE_HEAP = HEAP_NATIVE+1 }; Loading Loading @@ -137,6 +138,72 @@ static jlong android_os_Debug_getNativeHeapFreeSize(JNIEnv *env, jobject clazz) #endif } // XXX Qualcom-specific! static jlong read_gpu_mem(int pid) { char line[1024]; jlong uss = 0; unsigned temp; char tmp[128]; FILE *fp; sprintf(tmp, "/d/kgsl/proc/%d/mem", pid); fp = fopen(tmp, "r"); if (fp == 0) { //ALOGI("Unable to open: %s", tmp); return 0; } while (true) { if (fgets(line, 1024, fp) == NULL) { break; } //ALOGI("Read: %s", line); // Format is: // gpuaddr useraddr size id flags type usage sglen // 54676000 54676000 4096 1 ----p gpumem arraybuffer 1 // // If useraddr is 0, this is gpu mem not otherwise accounted // against the process. // Make sure line is long enough. int i = 0; while (i < 9) { if (line[i] == 0) { break; } i++; } if (i < 9) { //ALOGI("Early line term!"); continue; } // Look to see if useraddr is 00000000. while (i < 17) { if (line[i] != '0') { break; } i++; } if (i < 17) { //ALOGI("useraddr not 0!"); continue; } uss += atoi(line + i); //ALOGI("Uss now: %ld", uss); } fclose(fp); // Convert from bytes to KB. return uss / 1024; } static void read_mapinfo(FILE *fp, stats_t* stats) { char line[1024]; Loading Loading @@ -340,6 +407,10 @@ static void android_os_Debug_getDirtyPagesPid(JNIEnv *env, jobject clazz, load_maps(pid, stats); jlong gpu = read_gpu_mem(pid); stats[HEAP_GPU].pss += gpu; stats[HEAP_GPU].privateDirty += gpu; for (int i=_NUM_CORE_HEAP; i<_NUM_EXCLUSIVE_HEAP; i++) { stats[HEAP_UNKNOWN].pss += stats[i].pss; stats[HEAP_UNKNOWN].swappablePss += stats[i].swappablePss; Loading Loading @@ -394,10 +465,12 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid, jl char tmp[128]; FILE *fp; pss = uss = read_gpu_mem(pid); sprintf(tmp, "/proc/%d/smaps", pid); fp = fopen(tmp, "r"); if (fp == 0) return 0; if (fp != 0) { while (true) { if (fgets(line, 1024, fp) == NULL) { break; Loading @@ -422,6 +495,7 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid, jl } fclose(fp); } if (outUss != NULL) { if (env->GetArrayLength(outUss) >= 1) { Loading