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

前端 未结 9 2344
清酒与你
清酒与你 2020-11-21 06:27

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?

9条回答
  •  自闭症患者
    2020-11-21 07:04

    1) I guess not, at least not from Java.
    2)

    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    activityManager.getMemoryInfo(mi);
    Log.i("memory free", "" + mi.availMem);
    

提交回复
热议问题