tree: 388b57480077d35348e6144a4030dde95676ecd0 [path history] [tgz]
  1. bookkeeping.cc
  2. bookkeeping.h
  3. bookkeeping_unittest.cc
  4. bounded_queue.h
  5. bounded_queue_unittest.cc
  6. BUILD.gn
  7. client.cc
  8. client.h
  9. client_unittest.cc
  10. heapprofd_integrationtest.cc
  11. heapprofd_producer.cc
  12. heapprofd_producer.h
  13. main.cc
  14. malloc_hooks.cc
  15. queue_messages.h
  16. README.md
  17. record_reader.cc
  18. record_reader.h
  19. record_reader_unittest.cc
  20. sampler.cc
  21. sampler.h
  22. sampler_unittest.cc
  23. socket_listener.cc
  24. socket_listener.h
  25. socket_listener_unittest.cc
  26. string_interner.cc
  27. string_interner.h
  28. string_interner_unittest.cc
  29. unwinding.cc
  30. unwinding.h
  31. unwinding_fuzzer.cc
  32. unwinding_unittest.cc
  33. wire_protocol.cc
  34. wire_protocol.h
  35. wire_protocol_unittest.cc
src/profiling/memory/README.md

heapprofd - Android Heap Profiler

These are temporary instructions while heapprofd is under development. They are subject to frequent change and will be obsoleted once heapprofd is integrated into Perfetto.

Currently heapprofd only works with SELinux disabled and when run as root.

To start profiling the process ${PID}, run the following sequence of commands. Adjust the INTERVAL to trade-off runtime impact for higher accuracy of the results. If INTERVAL=1, every allocation is sampled for maximum accuracy. Otherwise, a sample is taken every INTERVAL bytes on average.

INTERVAL=128000

adb root
adb shell setenforce 0
adb shell heapprofd -s -i ${INTERVAL} &
adb shell kill -36 ${PID} # Start profiling the process.

To obtain heap dumps for all profiled processes, send SIGUSR1 to heapprofd which produces heap dumps in /data/local/tmp.

adb shell killall -USR1 heapprofd
adb pull /data/local/tmp/heap_dump.${PID}

This file can then be converted to a flamegraph using Brendan Gregg's flamegraph.pl.

flamegraph.pl heap_dump.${PID} > heap_dump.${PID}.svg