当前位置: 首页>>代码示例>>Java>>正文


Java MemoryInfo.getTotalPrivateDirty方法代码示例

本文整理汇总了Java中android.os.Debug.MemoryInfo.getTotalPrivateDirty方法的典型用法代码示例。如果您正苦于以下问题:Java MemoryInfo.getTotalPrivateDirty方法的具体用法?Java MemoryInfo.getTotalPrivateDirty怎么用?Java MemoryInfo.getTotalPrivateDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Debug.MemoryInfo的用法示例。


在下文中一共展示了MemoryInfo.getTotalPrivateDirty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrivDirty

import android.os.Debug.MemoryInfo; //导入方法依赖的package包/类
/**
 * 获取进程内存Private Dirty数据
 * 
 * @param context Android上下文
 * @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];
	long[] value = new long[3]; // Natvie Dalvik Total
	value[0] = pidMemoryInfo.nativePrivateDirty;
	value[1] = pidMemoryInfo.dalvikPrivateDirty;
	value[2] = pidMemoryInfo.getTotalPrivateDirty();
	return value;
}
 
开发者ID:r551,项目名称:GTTools,代码行数:22,代码来源:MEMUtils.java

示例2: getRunningApplication

import android.os.Debug.MemoryInfo; //导入方法依赖的package包/类
public static List<AppInfo> getRunningApplication(Context context) {
	MemoryInfo processMemoryInfo;
	PackageManager pm = context.getPackageManager();
	ActivityManager am = (ActivityManager) context
			.getSystemService(Context.ACTIVITY_SERVICE);
	List<RunningAppProcessInfo> runningAppProcesses = am
			.getRunningAppProcesses();
	List<AppInfo> list = new ArrayList<AppInfo>();
	for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
		AppInfo info = new AppInfo();
		processMemoryInfo = am
				.getProcessMemoryInfo(new int[] { runningAppProcessInfo.pid })[0];
		long mem = processMemoryInfo.getTotalPrivateDirty() * 1024L;
		info.mem = mem;
		info.packagename = runningAppProcessInfo.processName;
		try {
			ApplicationInfo applicationInfo = pm.getApplicationInfo(
					runningAppProcessInfo.processName, 0);
			info.sysApp = ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
					|| ((applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
			info.icon = applicationInfo.loadIcon(pm);
			info.name = applicationInfo.loadLabel(pm).toString();
			list.add(info);
		} catch (NameNotFoundException e) {
			e.printStackTrace();
			info = null;
		}
	}
	return list;
}
 
开发者ID:silvernoo,项目名称:KillTask,代码行数:31,代码来源:ApplicationUtils.java

示例3: getMemoryStatus

import android.os.Debug.MemoryInfo; //导入方法依赖的package包/类
/**
 * Get system memory status.
 * 
 * <p>Info taken from: http://huenlil.pixnet.net/blog/post/26872625
 * 
 * @return a description of the current status.
 */
public static String getMemoryStatus() {
    MemoryInfo memoryInfo = new android.os.Debug.MemoryInfo();
    android.os.Debug.getMemoryInfo(memoryInfo);

    /*
     * The Pss number is a metric the kernel computes that takes into 
     * account memory sharing -- basically each page of RAM in a process 
     * is scaled by a ratio of the number of other processes also using 
     * that page. This way you can (in theory) add up the pss across all 
     * processes to see the total RAM they are using, and compare pss between 
     * processes to get a rough idea of their relative weight.
     */
    double totalPss = memoryInfo.getTotalPss() / 1024.0;
    /*
     * The other interesting metric here is PrivateDirty, which is basically 
     * the amount of RAM inside the process that can not be paged to disk 
     * (it is not backed by the same data on disk), and is not shared with 
     * any other processes. Another way to look at this is the RAM that will 
     * become available to the system when that process goes away (and probably 
     * quickly subsumed into caches and other uses of it).
     */
    double totalPrivateDirty = memoryInfo.getTotalPrivateDirty() / 1024.0;
    double totalSharedDirty = memoryInfo.getTotalSharedDirty() / 1024.0;
    String memMessage = String.format("Memory Pss=%.2f MB\nMemory Private=%.2f MB\nMemory Shared=%.2f MB", totalPss,
            totalPrivateDirty, totalSharedDirty);
    return memMessage;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:35,代码来源:Debug.java


注:本文中的android.os.Debug.MemoryInfo.getTotalPrivateDirty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。