HOW DO I DISCOVER MEMORY USAGE OF MY APPLICATION IN ANDROID?

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
 839  View(s)
Ratings:
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?

  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: How do I discover memory usage of my application in Android?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!