1# Quickstart: Heap profiling 2 3## Prerequisites 4 5* [ADB](https://developer.android.com/studio/command-line/adb) installed. 6* A device running Android 10+. 7* A _Profileable_ or _Debuggable_ app. If you are running on a _"user"_ build of 8 Android (as opposed to _"userdebug"_ or _"eng"_), your app needs to be marked 9 as profileable or debuggable in its manifest. 10 See the [heapprofd documentation][hdocs] for more details. 11 12[hdocs]: /docs/data-sources/native-heap-profiler.md#heapprofd-targets 13 14## Capture a heap profile 15 16### Linux / macOS 17Make sure adb is installed and in your PATH. 18 19```bash 20adb devices -l 21``` 22 23If more than one device or emulator is reported you must select one upfront as follows: 24 25```bash 26export ANDROID_SERIAL=SER123456 27``` 28 29Download the `tools/heap_profile` (if you don't have a perfetto checkout): 30 31```bash 32curl -LO https://raw.githubusercontent.com/google/perfetto/master/tools/heap_profile 33chmod +x heap_profile 34``` 35 36Then start the profile: 37 38```bash 39./heap_profile -n system_server 40``` 41 42### Windows 43 44Make sure that the downloaded adb.exe is in the PATH. 45 46```bash 47set PATH=%PATH%;%USERPROFILE%\Downloads\platform-tools 48 49adb devices -l 50``` 51 52If more than one device or emulator is reported you must select one upfront as follows: 53 54```bash 55set ANDROID_SERIAL=SER123456 56``` 57 58Download the 59[heap_profile](https://raw.githubusercontent.com/google/perfetto/master/tools/heap_profile) 60script. Then start the profile: 61 62```bash 63python /path/to/heap_profile -n system_server 64``` 65 66## View profile 67 68Upload the `raw-trace` file from the output directory to the [Perfetto UI]( 69https://ui.perfetto.dev) and click on diamond marker in the UI track labeled 70_"Heap profile"_. 71 72![Profile Diamond](/docs/images/profile-diamond.png) 73![Native Flamegraph](/docs/images/syssrv-apk-assets-two.png) 74 75## Next steps 76 77Learn more about memory debugging in the [Memory Usage on Android Guide]( 78/docs/case-studies/memory.md) and more about the [heapprofd data-source]( 79/docs/data-sources/native-heap-profiler.md) 80