blob: 755a429d7ce04851539f5c955df6b20c4ec7a15b [file] [log] [blame] [view]
Dianne Hackborn89bfe312011-07-26 21:55:07 -07001<!--
2 Copyright 2011 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16
Jean-Baptiste Queru93b0f182011-07-30 18:19:08 -070017# Debugging Native Memory Use #
Dianne Hackborn89bfe312011-07-26 21:55:07 -070018
Jean-Baptiste Queru93b0f182011-07-30 18:19:08 -070019This tip assume that you are working with an eng
Dianne Hackborn89bfe312011-07-26 21:55:07 -070020or userdebug build of the platform, not on a production device.
21
Dianne Hackborn89bfe312011-07-26 21:55:07 -070022Android's native memory allocator has some useful debugging features. You
23can turn on memory tracking with:
24
25 $ adb shell setprop libc.debug.malloc 1
26 $ adb shell stop
27 $ adb shell start
28
29You need to restart the runtime so that zygote and all processes launched from
30it are restarted with the property set. Now all Dalvik processes have memory
31tracking turned on. You can look at these with DDMS, but first you need to
32turn on its native memory UI:
33
34 - Open ~/.android/ddms.cfg
35 - Add a line "native=true"
36
37Upon relaunching DDMS and selecting a process, you can switch to the new
38native allocation tab and populate it with a list of allocations. This is
39especially useful for debugging memory leaks.