Dianne Hackborn | 89bfe31 | 2011-07-26 21:55:07 -0700 | [diff] [blame^] | 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 | # Development Tips and Tricks # |
| 18 | |
| 19 | A collection of helpful tricks and available facilities for developing |
| 20 | the platform code. This tips assume that you are working with an eng |
| 21 | or userdebug build of the platform, not on a production device. |
| 22 | |
| 23 | ## Debugging Native Memory Use ## |
| 24 | |
| 25 | Android's native memory allocator has some useful debugging features. You |
| 26 | can turn on memory tracking with: |
| 27 | |
| 28 | $ adb shell setprop libc.debug.malloc 1 |
| 29 | $ adb shell stop |
| 30 | $ adb shell start |
| 31 | |
| 32 | You need to restart the runtime so that zygote and all processes launched from |
| 33 | it are restarted with the property set. Now all Dalvik processes have memory |
| 34 | tracking turned on. You can look at these with DDMS, but first you need to |
| 35 | turn on its native memory UI: |
| 36 | |
| 37 | - Open ~/.android/ddms.cfg |
| 38 | - Add a line "native=true" |
| 39 | |
| 40 | Upon relaunching DDMS and selecting a process, you can switch to the new |
| 41 | native allocation tab and populate it with a list of allocations. This is |
| 42 | especially useful for debugging memory leaks. |