码迷,mamicode.com
首页 > 其他好文 > 详细

ActivityManager(二)--获取应用所占内存大小

时间:2014-09-21 21:06:21      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:blog   java   for   2014   cti   on   log   c   new   

	private void getRunningAppProcessInfo() {
		mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);

		//获得系统里正在运行的所有进程
		List<RunningAppProcessInfo> runningAppProcessesList = mActivityManager.getRunningAppProcesses();

		for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcessesList) {
			// 进程ID号
			int pid = runningAppProcessInfo.pid;
			// 用户ID
			int uid = runningAppProcessInfo.uid;
			// 进程名
			String processName = runningAppProcessInfo.processName;
			// 占用的内存
			int[] pids = new int[] {pid};
			Debug.MemoryInfo[] memoryInfo = mActivityManager.getProcessMemoryInfo(pids);
			int memorySize = memoryInfo[0].dalvikPrivateDirty;

			System.out.println("processName="+processName+",pid="+pid+",uid="+uid+",memorySize="+memorySize+"kb");
		}
	}


ActivityManager(二)--获取应用所占内存大小

标签:blog   java   for   2014   cti   on   log   c   new   

原文地址:http://blog.csdn.net/lfdfhl/article/details/39453477

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!