Android Studio中的内存监视器报告比设备不同的内存占用 [英] Memory monitor in Android Studio reports different RAM usage than the device

查看:1098
本文介绍了Android Studio中的内存监视器报告比设备不同的内存占用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调查一个应用程序我工作的RAM使用,我一直在使用Android Studio中的内存监控工具(可在Android的工作室通过工具> Android的>内存监视器访问)。我注意到,在内存箴言报我的应用程序的内存使用,始终是从设备查看内存使用情况时比低得多(可以进入设置>应用程序>运行访问)。正如你可以在下面的截图看到,内存监视器报告有关RAM的使用(23MB如果包括自由空间)的18MB,但设备报告43MB。

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>Android>Memory Monitor). I have noticed the RAM usage of my app that is reported in Memory Monitor, is always far lower than when viewing the RAM usage from the device (can be accessed by going to Settings>Apps>Running). As you can see in the screenshots below, Memory Monitor is reporting about 18MB of RAM usage (23MB if you include free space), but the device is reporting 43MB.

为什么差也比其他

推荐答案

我怀疑是内存监控工具谈论有关Java的code制成堆分配​​的Dalvik虚拟机,设备管理器显示什么整个过程使用的内存。所以第一不包括架空或使用由虚拟机本身(或它的文本和库),或任何偏离堆分配(有时天然code可以分配存储器不直接可见到VM)存储器。

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).

请参阅https://developer.android.com/tools/debugging/debugging-memory.html#ViewingAllocations并尝试运行命令:

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

adb shell dumpsys meminfo <package_name>

让你的应用程序运行时内存的使用更precise击穿。

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

这篇关于Android Studio中的内存监视器报告比设备不同的内存占用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆