Debugging Native Memory Use

来自:http://source.android.com/devices/tech/debug/native-memory.html

 

Debugging Native Memory Use 

 

This tip assumes 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 app 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.

 

posted @ 2016-04-18 21:55  dolinux  阅读(193)  评论(0)    收藏  举报