Context context = this.getApplicationContext(); ActivityManager mgr = (ActivityManager)context.getSystemService(ACTIVITY_SERVICE); List<RunningAppProcessInfo> processes = mgr.getRunningAppProcesses(); Log.e("DEBUG", "Running processes:"); for(Iterator i = processes.iterator(); i.hasNext(); ) { RunningAppProcessInfo p = (RunningAppProcessInfo)i.next(); Log.e("DEBUG", " process name: "+p.processName); Log.e("DEBUG", " pid: "+p.pid); int[] pids = new int[1]; pids[0] = p.pid; android.os.Debug.MemoryInfo[] MI = mgr.getProcessMemoryInfo(pids); Log.e("memory"," dalvik private: " + MI[0].dalvikPrivateDirty); Log.e("memory"," dalvik shared: " + MI[0].dalvikSharedDirty); Log.e("memory"," dalvik pss: " + MI[0].dalvikPss); Log.e("memory"," native private: " + MI[0].nativePrivateDirty); Log.e("memory"," native shared: " + MI[0].nativeSharedDirty); Log.e("memory"," native pss: " + MI[0].nativePss); Log.e("memory"," other private: " + MI[0].otherPrivateDirty); Log.e("memory"," other shared: " + MI[0].otherSharedDirty); Log.e("memory"," other pss: " + MI[0].otherPss); Log.e("memory"," total private dirty memory (KB): " + MI[0].getTotalPrivateDirty()); Log.e("memory"," total shared (KB): " + MI[0].getTotalSharedDirty()); Log.e("memory"," total pss: " + MI[0].getTotalPss()); }
In modern operating systems, applications use shared libraries. Consequently, some memory is used by several applications, which complicates the determination of application memory usage.
dalvikPrivateDirty is the memory to be freed by java
virtual machine if the process is killed
- nativePrivateDirty is the same for native code, the same for some other code (not sure what else is)
otherPrivateDirty dalvikSharedDirty is the shared memory used by the java virtual machine But this will not be freed
if this application is killed by dalvikPss - an estimate of the amount of memory used by the application. This includes all personal memory and a fraction of the total memory. Make sure pss> = private. The reason is that only part of the shared memory is used, so the wisdom of using shared memory in all critical applications
This value is used to evaluate application memory usage.
Amounts represent the amount for dalwick, native and others.
source share