Quickstart: Heap profiling
Prerequisites
- ADB installed.
- A device running Android 10+.
- A Profileable or Debuggable app. If you are running on a "user" build of Android (as opposed to "userdebug" or "eng"), your app needs to be marked as profileable or debuggable in its manifest. See the heapprofd documentation for more details.
Capture a heap profile
Linux / macOS
Make sure adb is installed and in your PATH.
adb devices -lIf more than one device or emulator is reported you must select one upfront as follows:
export ANDROID_SERIAL=SER123456Download the tools/heap_profile (if you don't have a perfetto checkout):
curl -LO https://raw.githubusercontent.com/google/perfetto/main/tools/heap_profile
chmod +x heap_profileThen start the profile:
./heap_profile -n system_serverWindows
Make sure that the downloaded adb.exe is in the PATH.
set PATH=%PATH%;%USERPROFILE%\Downloads\platform-tools
adb devices -lIf more than one device or emulator is reported you must select one upfront as follows:
set ANDROID_SERIAL=SER123456Download the heap_profile script. Then start the profile:
python /path/to/heap_profile -n system_serverView profile
Upload the raw-trace file from the output directory to the Perfetto UI and click on diamond marker in the UI track labeled
"Heap profile".

Next steps
Learn more about memory debugging in the Memory Usage on Android Guide and more about the heapprofd data-source

