Detect application heap size in Android

后端 未结 9 1956
-上瘾入骨i
-上瘾入骨i 2020-11-22 07:38

How do you programmatically detect the application heap size available to an Android app?

I heard there\'s a function that does this in later versions of the SDK. In

9条回答
  •  孤街浪徒
    2020-11-22 08:11

    Runtime rt = Runtime.getRuntime();
    rt.maxMemory()
    

    value is b

    ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    am.getMemoryClass()
    

    value is MB

提交回复
热议问题