Home > DeveloperSection > Forums > How do I discover memory usage of my application in Android?
ben reitman
ben reitman

Total Post:96

Points:676
Posted on    May-29-2015 12:40 AM

 Android Android 
Ratings:


 1 Reply(s)
 494  View(s)
Rate this:

How can I find the memory used on my Android application, programmatically?

I hope there is a way to do it. Plus, how do I get the free memory of the phone too?



Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Posted on    May-29-2015 7:37 AM

Yes, you can get memory info programmatically and decide whether to do memory intensive work.

Get VM Heap Size by calling:

Runtime.getRuntime().totalMemory();
Get Allocated VM Memory by calling:

Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
Get VM Heap Size Limit by calling:

Runtime.getRuntime().maxMemory()
Get Native Allocated Memory by calling:

Debug.getNativeHeapAllocatedSize();
tere is an app to figure out the OutOfMemoryError behavior and monitor memory usage.

https://play.google.com/store/apps/details?id=net.coocood.oomresearch

You can get the source code at https://github.com/coocood/oom-research

Don't want to miss updates? Please click the below button!

Follow MindStick