Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to checking memory in android with button
Posted

Hackbod's is one of the best answers in SO. It throws light on a very obscure subject. It helped me a lot.

Another really helpful resource is this must-see video: [Google I/O 2011: Memory management for Android Apps][1]

---

**UPDATE:**

Process Stats, a service to discover how your app manages memory explained at this post by Dianne Hackborn: [http://android-developers.blogspot.com.es/2014/01/process-stats-understanding-how-your.html](http://android-developers.blogspot.com.es/2014/01/process-stats-understanding-how-your.html)


[1]: link
 
Share this answer
 
v2
Well, you can check memory usage in Android with
getProcessMemoryInfo
function supported by Android.
ActivityManager activityManager = (ActivityManager)mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<runningappprocessinfo> runningApps = activityManager.getRunningAppProcesses();
int pids[] = new int[runningApps.size()];
String processNames[] = new String[runningApps.size()];
int i = 0;
for(RunningAppProcessInfo app : runningApps) {
  pids[i] = app.pid;
  processNames[i] = app.processName;
  ++i;
}
android.os.Debug.MemoryInfo[] memInfos = activityManager.getProcessMemoryInfo(pids);
long totalPss = 0;
i = 0;
for (android.os.Debug.MemoryInfo info : memInfos) {
  Log.d(TAG, "[" + processNames[i] + "] total pss[KB] = " + info.getTotalPss());
  ++i;
  totalPss += info.getTotalPss();
}
Log.d(TAG, "TOTAL pss[KB] = " + totalPss);</runningappprocessinfo>

Details are listed here!!
http://www.notice.co.jp/archives/3041[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900