Detect application heap size in Android

后端 未结 9 2160
-上瘾入骨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 07:51

    This returns max heap size in bytes:

    Runtime.getRuntime().maxMemory()
    

    I was using ActivityManager.getMemoryClass() but on CyanogenMod 7 (I didn't test it elsewhere) it returns wrong value if the user sets heap size manually.

提交回复
热议问题