• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!--
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
17# Debugging Native Memory Use #
18
19This tip assume that you are working with an eng
20or userdebug build of the platform, not on a production device.
21
22Android'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.
40