use of android.os.Debug.MemoryInfo in project GT by Tencent.
the class MemUtils method getPSS.
/**
* 获取进程内存PSS数据
*
* @param context
* @param pid
* @return nativePss、dalvikPss、TotalPss
*/
public static long[] getPSS(Context context, int pid) {
// Natvie Dalvik Total
long[] value = new long[3];
if (pid >= 0) {
int[] pids = new int[1];
pids[0] = pid;
ActivityManager mAm = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo[] memoryInfoArray = mAm.getProcessMemoryInfo(pids);
MemoryInfo pidMemoryInfo = memoryInfoArray[0];
value[0] = pidMemoryInfo.nativePss;
value[1] = pidMemoryInfo.dalvikPss;
value[2] = pidMemoryInfo.getTotalPss();
} else {
value[0] = 0;
value[1] = 0;
value[2] = 0;
}
return value;
}
use of android.os.Debug.MemoryInfo in project GT by Tencent.
the class MemUtils method getPrivDirty.
/**
* 获取进程内存Private Dirty数据
*
* @param context
* @param pid
* 进程ID
* @return nativePrivateDirty、dalvikPrivateDirty、 TotalPrivateDirty
*/
public static long[] getPrivDirty(Context context, int pid) {
ActivityManager mAm = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int[] pids = new int[1];
pids[0] = pid;
MemoryInfo[] memoryInfoArray = mAm.getProcessMemoryInfo(pids);
MemoryInfo pidMemoryInfo = memoryInfoArray[0];
// Natvie Dalvik Total
long[] value = new long[3];
value[0] = pidMemoryInfo.nativePrivateDirty;
value[1] = pidMemoryInfo.dalvikPrivateDirty;
value[2] = pidMemoryInfo.getTotalPrivateDirty();
return value;
}
use of android.os.Debug.MemoryInfo in project android_frameworks_base by ParanoidAndroid.
the class MemoryUsageTest method getPss.
private int getPss(String processName) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
for (RunningAppProcessInfo proc : apps) {
if (!proc.processName.equals(processName)) {
continue;
}
int[] pids = { proc.pid };
MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
return meminfo.getTotalPss();
}
return -1;
}
use of android.os.Debug.MemoryInfo in project android_frameworks_base by crdroidandroid.
the class MemoryUsageTest method getPss.
private int getPss(String processName) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
for (RunningAppProcessInfo proc : apps) {
if (!proc.processName.equals(processName)) {
continue;
}
int[] pids = { proc.pid };
MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
return meminfo.getTotalPss();
}
return -1;
}
use of android.os.Debug.MemoryInfo in project platform_frameworks_base by android.
the class MemoryUsageTest method getPss.
private int getPss(String processName) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
for (RunningAppProcessInfo proc : apps) {
if (!proc.processName.equals(processName)) {
continue;
}
int[] pids = { proc.pid };
MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
return meminfo.getTotalPss();
}
return -1;
}
Aggregations