0

I am struggling for a solution to find the memory used by particular process in android.

Using actvityManager.getRunningAppProcesses() I can able to get the consolidated list of all process's memory usage.

But i need to implement a scenario where I should pass the processID and get the memory usage of particular process? Is this scenario possible in Android?

Thanks in Advance!

Shruti
  • 1
  • 13
  • 55
  • 95
macOsX
  • 447
  • 1
  • 9
  • 19

2 Answers2

3

You can get the memory info using

MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);

and for a particular process use

activityManager.getProcessMemoryInfo(new int[]{process_ids}); 

which returns an array of memory information

I would ask you to refere these three

Get Memory Usage in Android

How to get current memory usage in android?

How do I discover memory usage of my application in Android?

Community
  • 1
  • 1
Girish Nair
  • 5,148
  • 5
  • 40
  • 61
0

See these links:

https://stackoverflow.com/a/2299813/1369222

http://macgyverdev.blogspot.in/2011/11/android-track-down-memory-leaks.html

Note that this isn't an exact science and instead of looking for a general "memory usage of a process" you should be looking for something more specific to your requirements. Anyway, those links will help you get started.

Community
  • 1
  • 1
Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84