Memory monitor in Android Studio reports different RAM usage than the device

前端 未结 2 1201
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 07:54

When investigating RAM usage in an app I am working on, I have been using the Memory Monitor tool in Android Studio (can be accessed in Android Studio by going to Tools>Andr

2条回答
  •  隐瞒了意图╮
    2021-01-04 08:27

    I suspect that the memory monitor tool is talking to the dalvik virtual machine about heap allocations made by Java code, and the device manager is showing what the entire process is using for memory. So the first does not include overhead or memory used by the virtual machine itself (or its text and libraries), or any off-heap allocations (sometimes native code can allocate memory that isn't directly visible to the VM).

    See https://developer.android.com/tools/debugging/debugging-memory.html#ViewingAllocations and try running the command:

    adb shell dumpsys meminfo 
    

    to get a more precise breakdown of the run-time memory usage of your application.

提交回复
热议问题