18

I have developed a file parsing application on the android platform. How do I check how much memory my application is actually using up ? I tried the adb shell cat /proc/meminfo command but this does not give me how much memory my application is using. it just gives general info about the overall memory. And how much memory should an application typically use up ? what is usual or unusual ? Any help is appreciated. Thanks !

Amritha
  • 795
  • 3
  • 9
  • 26

5 Answers5

18

Android apps are constrained to a certain amount of memory. As it's quite (insanely?) low, I think you shouldn't feel guilty about using all of it!

The limit is 16 MB on very old devices, 24 MB or 32 MB on newer ones. There doesn't seem to be much info on the size for different devices, and nobody seems to know why the limit is so small when modern phones have 1-2 GB of RAM.

http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/

https://groups.google.com/forum/?fromgroups=#!topic/android-platform/7zKQlrDcypQ

Aha, I found some concrete numbers on the limit:

http://dubroy.com/memory_management_for_android_apps.pdf

G1: 16MB

Droid: 24MB

Nexus One: 32MB

Xoom: 48MB

Community
  • 1
  • 1
Timmmm
  • 88,195
  • 71
  • 364
  • 509
4

You can use DDMS > Allocation Tracker to track memory usage and Heap Allocation for your app

http://developer.android.com/resources/articles/track-mem.html

To Track the overall memory of a PID you could use following two methods in ActivityManager

To get a PID of your app :

List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses ()

and then the MemoryInfo

MemoryInfo[] getProcessMemoryInfo (int[] pids)
Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22
  • Using the allocation tracker helped me with debugging purposes, I want to find the memory occupied by my application as a whole. – Amritha Mar 28 '12 at 04:34
  • @Amritha: I think [MAT](http://www.vogella.de/articles/EclipseMemoryAnalyser/article.html) could help you with that. – Ghost Mar 28 '12 at 05:00
  • @Ghost, again I repeat, I do not want to debug or find where the objects are allocated or memory leaks. In the phone, I want to know how much memory my application is taking up. Thats it. – Amritha Mar 28 '12 at 05:13
  • @Amritha: See [this](http://stackoverflow.com/questions/4516645/how-can-i-see-how-much-memory-my-app-is-using-out-of-its-vm-budget) and [this](http://android-developers.blogspot.in/2011/03/memory-analysis-for-android.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/hsDu+%28Android+Developers+Blog%29). The scope of MAT just isn't limited to finding out memory leaks. It's pretty much obvious that if your app doesn't have leaks, MAT shows you the total memory being used by your app. If even this doesn't help you, then try [Google](https://www.google.com). All the best. – Ghost Mar 28 '12 at 05:39
1

you might want to take a look at this one. How do I discover memory usage of my application in Android? Or simply try

ActivityManager.getMemoryInfo() 
Community
  • 1
  • 1
Win Myo Htet
  • 5,377
  • 3
  • 38
  • 56
0

You can get the memory usage of your android application with the following command: Assuming you have adb in PATH:

adb shell dumpsys meminfo com.<your.package>

To see live updation of memory in use, you can try

watch "adb shell dumpsys meminfo com.<your.package>"

Hope this helps

0

you can check the application memory usage in application mananger, you can check it in the link

Rakshi
  • 6,796
  • 3
  • 25
  • 46