Download the tools/heap_profile
(if you don't have a perfetto checkout) and run it as follows:
curl -LO https://raw.githubusercontent.com/google/perfetto/master/tools/heap_profile chmod +x heap_profile ./heap_profile -n system_server Profiling active. Press Ctrl+C to terminate. You may disconnect your device. Wrote profiles to /tmp/profile-1283e247-2170-4f92-8181-683763e17445 (symlink /tmp/heap_profile-latest) These can be viewed using pprof. Googlers: head to pprof/ and upload them.
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”.
Learn more about memory debugging in the Memory Usage on Android Guide and more about the heapprofd data-source