Android获取应用所占内存大小

	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");
		}
	}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。