Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
include/perfetto/ | 03-May-2024 | - | 190 | 46 | ||
shared_ring_buffer_fuzzer_corpus/ | 03-May-2024 | - | ||||
test/data/ | 03-May-2024 | - | 133 | 132 | ||
BUILD.gn | D | 03-May-2024 | 10.5 KiB | 410 | 381 | |
CHANGELOG.md | D | 03-May-2024 | 1.4 KiB | 36 | 30 | |
README.md | D | 03-May-2024 | 3 KiB | 91 | 64 | |
bookkeeping.cc | D | 03-May-2024 | 7.1 KiB | 194 | 134 | |
bookkeeping.h | D | 03-May-2024 | 14.2 KiB | 372 | 206 | |
bookkeeping_dump.cc | D | 03-May-2024 | 4.1 KiB | 116 | 70 | |
bookkeeping_dump.h | D | 03-May-2024 | 3.9 KiB | 119 | 78 | |
bookkeeping_unittest.cc | D | 03-May-2024 | 11.3 KiB | 318 | 260 | |
client.cc | D | 03-May-2024 | 16.8 KiB | 508 | 370 | |
client.h | D | 03-May-2024 | 5 KiB | 149 | 80 | |
client_api.cc | D | 03-May-2024 | 18.6 KiB | 555 | 385 | |
client_api_benchmark.cc | D | 03-May-2024 | 7 KiB | 232 | 165 | |
client_api_factory.h | D | 03-May-2024 | 1.1 KiB | 38 | 13 | |
client_api_factory_android.cc | D | 03-May-2024 | 1.8 KiB | 60 | 34 | |
client_api_factory_standalone.cc | D | 03-May-2024 | 5.4 KiB | 182 | 126 | |
client_api_noop.cc | D | 03-May-2024 | 2 KiB | 70 | 43 | |
client_api_unittest.cc | D | 03-May-2024 | 4.3 KiB | 129 | 86 | |
client_unittest.cc | D | 03-May-2024 | 4.4 KiB | 148 | 101 | |
heap_profile_internal.h | D | 03-May-2024 | 1.3 KiB | 48 | 21 | |
heapprofd_client_api.map.txt | D | 03-May-2024 | 461 | 19 | 17 | |
heapprofd_end_to_end_test.cc | D | 03-May-2024 | 59.9 KiB | 1,772 | 1,429 | |
heapprofd_preload.map.txt | D | 03-May-2024 | 174 | 16 | 15 | |
heapprofd_producer.cc | D | 03-May-2024 | 45.1 KiB | 1,278 | 1,057 | |
heapprofd_producer.h | D | 03-May-2024 | 11.6 KiB | 336 | 210 | |
heapprofd_producer_unittest.cc | D | 03-May-2024 | 8.8 KiB | 244 | 203 | |
heapprofd_standalone_client_example.cc | D | 03-May-2024 | 989 | 36 | 14 | |
java_hprof_producer.cc | D | 03-May-2024 | 7.5 KiB | 236 | 186 | |
java_hprof_producer.h | D | 03-May-2024 | 3.4 KiB | 104 | 66 | |
log_histogram.cc | D | 03-May-2024 | 1.6 KiB | 67 | 39 | |
log_histogram.h | D | 03-May-2024 | 1.3 KiB | 48 | 22 | |
main.cc | D | 03-May-2024 | 4.2 KiB | 132 | 88 | |
malloc_interceptor_bionic_hooks.cc | D | 03-May-2024 | 8.8 KiB | 243 | 159 | |
malloc_interceptor_glibc_preload.cc | D | 03-May-2024 | 3.4 KiB | 109 | 70 | |
parse_smaps_unittest.cc | D | 03-May-2024 | 2.6 KiB | 94 | 66 | |
sampler.cc | D | 03-May-2024 | 1.6 KiB | 52 | 23 | |
sampler.h | D | 03-May-2024 | 3.1 KiB | 95 | 43 | |
sampler_unittest.cc | D | 03-May-2024 | 1.6 KiB | 59 | 34 | |
scoped_spinlock.cc | D | 03-May-2024 | 2 KiB | 68 | 39 | |
scoped_spinlock.h | D | 03-May-2024 | 2.5 KiB | 101 | 65 | |
shared_ring_buffer.cc | D | 03-May-2024 | 10.6 KiB | 343 | 248 | |
shared_ring_buffer.h | D | 03-May-2024 | 9 KiB | 274 | 169 | |
shared_ring_buffer_fuzzer.cc | D | 03-May-2024 | 3.2 KiB | 103 | 64 | |
shared_ring_buffer_unittest.cc | D | 03-May-2024 | 8.6 KiB | 280 | 224 | |
shared_ring_buffer_write_fuzzer.cc | D | 03-May-2024 | 3.2 KiB | 107 | 68 | |
system_property.cc | D | 03-May-2024 | 5.2 KiB | 176 | 131 | |
system_property.h | D | 03-May-2024 | 2.8 KiB | 90 | 42 | |
system_property_unittest.cc | D | 03-May-2024 | 5.2 KiB | 159 | 127 | |
unhooked_allocator.h | D | 03-May-2024 | 2.7 KiB | 89 | 49 | |
unwinding.cc | D | 03-May-2024 | 16.2 KiB | 458 | 360 | |
unwinding.h | D | 03-May-2024 | 5.6 KiB | 161 | 101 | |
unwinding_fuzzer.cc | D | 03-May-2024 | 2.4 KiB | 71 | 44 | |
unwinding_unittest.cc | D | 03-May-2024 | 6.7 KiB | 190 | 145 | |
unwound_messages.h | D | 03-May-2024 | 1.6 KiB | 60 | 33 | |
util.h | D | 03-May-2024 | 1.1 KiB | 28 | 4 | |
wire_protocol.cc | D | 03-May-2024 | 5.7 KiB | 184 | 148 | |
wire_protocol.h | D | 03-May-2024 | 6.3 KiB | 183 | 107 | |
wire_protocol_unittest.cc | D | 03-May-2024 | 6.3 KiB | 177 | 137 | |
wrap_allocators.cc | D | 03-May-2024 | 4.6 KiB | 138 | 92 | |
wrap_allocators.h | D | 03-May-2024 | 2 KiB | 58 | 35 |
README.md
1# heapprofd - Android Heap Profiler 2 3heapprofd allows you to attribute memory usage to functions for Android services 4and apps. 5 6For documentation, see https://perfetto.dev/docs/data-sources/native-heap-profiler. 7 8For design doc, see https://perfetto.dev/docs/design-docs/heapprofd-design. 9 10## GN Targets 11### Factories 12android: connects to the system heapprofd. The client API will need to have 13 been built at *exactly* the same version. This means this can only 14 be used by the API shipped in the platform. 15 16standalone: executes an in-process heapprofd. Can be used on old platform 17 versions. 18 19noop: ignores all calls to the client API. This can be used as a stand-in when 20 compiling, or when executing without profiling. 21 22### Interceptors 23bionic: uses bionic [malloc dispatch]( 24https://cs.android.com/android/platform/superproject/+/master:bionic/libc/private/bionic_malloc_dispatch.h) 25to intercept allocation functions on Android. This works by placing a library 26on a pre-defined path, which gets [loaded by Bionic]( 27https://cs.android.com/android/platform/superproject/+/master:bionic/libc/bionic/malloc_heapprofd.cpp). 28 29glibc: generates a library exposing the allocation functions. This library 30 should be used for `LD_PRELOAD` and uses the glibc specific symbols 31 like `__libc_malloc` to use the system allocator. 32 33### Shared libraries 34 35| GN target | factory | interceptor | distribution | 36|-----------------------------|------------|-------------|--------------| 37| heapprofd_client | android | bionic | platform | 38| heapprofd_client_api | android | none | platform | 39| heapprofd_glibc_preload | standalone | glibc | unbundled | 40| heapprofd_standalone_client | standalone | none | unbundled | 41| heapprofd_api_noop | noop | none | unbundled | 42 43 44## Heap profile heapprofd 45 46For development, you might want to get a heap profile of heapprofd while it 47is profiling something else. For that reason, we allow two heapprofds to run 48on the system. The secondary heapprofd can then profile your primary one. 49 50To do this, first make sure that heapprofd is running by setting the property 51 52``` 53adb shell su root setprop persist.heapprofd.enable 1 54``` 55 56Take note of its PID. 57 58``` 59adb shell ps -e | grep heapprofd 60``` 61 62Then, move away the primary heapprofd socket to make space for the secondary 63one 64 65``` 66adb shell su root mv /dev/socket/heapprofd /dev/socket/heapprofd_primary 67``` 68 69Start the secondary heapprofd 70 71``` 72adb shell su root start heapprofd_secondary 73``` 74 75Now we can start the profile of the primary heapprofd (using the secondary). 76Leave this session running. 77 78``` 79tools/heap_profile -p ${PID_FROM_ABOVE} 80``` 81 82Now move back the original socket 83 84``` 85adb shell su root unlink /dev/socket/heapprofd 86adb shell su root mv /dev/socket/heapprofd_primary /dev/socket/heapprofd 87``` 88 89Now all subsequent profiles will be done on the primary heapprofd again, with 90the secondary observing it. 91