分享

Debugging Native Memory Use | Android Developers

 老匹夫 2014-02-22

Debugging Native Memory Use

This tip assume that you are working with an eng or userdebug build of the platform, not on a production device.

Android's native memory allocator has some useful debugging features. You can turn on memory tracking with:

  $ adb shell setprop libc.debug.malloc 1
  $ adb shell stop
  $ adb shell start

You need to restart the runtime so that zygote and all processes launched from it are restarted with the property set. Now all Dalvik processes have memory tracking turned on. You can look at these with DDMS, but first you need to turn on its native memory UI:

  • Open ~/.android/ddms.cfg
  • Add a line "native=true"

Upon relaunching DDMS and selecting a process, you can switch to the new native allocation tab and populate it with a list of allocations. This is especially useful for debugging memory leaks.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多