OLD | NEW |
1 # Heap Profiling with MemoryInfra | 1 # Heap Profiling with MemoryInfra |
2 | 2 |
3 As of Chrome 48, MemoryInfra supports heap profiling. The core principle is | 3 As of Chrome 48, MemoryInfra supports heap profiling. The core principle is |
4 a solution that JustWorks™ on all platforms without patching or rebuilding, | 4 a solution that JustWorks™ on all platforms without patching or rebuilding, |
5 integrated with the chrome://tracing ecosystem. | 5 integrated with the chrome://tracing ecosystem. |
6 | 6 |
7 [TOC] | 7 [TOC] |
8 | 8 |
9 ## How to Use | 9 ## How to Use |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 [memory-infra]: README.md | 32 [memory-infra]: README.md |
33 [m-purple]: https://storage.googleapis.com/chromium-docs.appspot.com/d7bd
f4d16204c293688be2e5a0bcb2bf463dbbc3 | 33 [m-purple]: https://storage.googleapis.com/chromium-docs.appspot.com/d7bd
f4d16204c293688be2e5a0bcb2bf463dbbc3 |
34 [cells-heap-dump]: https://storage.googleapis.com/chromium-docs.appspot.com/a24d
80d6a08da088e2e9c8b2b64daa215be4dacb | 34 [cells-heap-dump]: https://storage.googleapis.com/chromium-docs.appspot.com/a24d
80d6a08da088e2e9c8b2b64daa215be4dacb |
35 | 35 |
36 ### Native stack traces | 36 ### Native stack traces |
37 | 37 |
38 By default heap profiling collects pseudo allocation traces, which are based | 38 By default heap profiling collects pseudo allocation traces, which are based |
39 on trace events. I.e. frames in allocation traces correspond to trace events | 39 on trace events. I.e. frames in allocation traces correspond to trace events |
40 that were active at the time of allocations, and are not real function names. | 40 that were active at the time of allocations, and are not real function names. |
41 However, you can build a special Linux / Android build that will collect | 41 It's also possible to use heap profiling with native, symbolized stack traces. |
42 real C/C++ stack traces. | 42 |
| 43 #### Native stack traces (Chrome - macOS/Windows) |
| 44 |
| 45 1. Using any officially distributed build of Chrome, navigate to chrome://flags, |
| 46 and set "enable-heap-profiling" to Enabled (native mode). |
| 47 |
| 48 2. Use the [TraceOnTap][extension-link] extension to grab a trace. |
| 49 |
| 50 3. Run the following script to symbolize the trace. |
| 51 |
| 52 third_party/catapult/tracing/bin/symbolize_trace <trace file> |
| 53 |
| 54 4. Load the trace file in `chrome://tracing`. Locate a purple ![M][m-purple] |
| 55 dot, and continue from step *3* from the instructions above. Native stack |
| 56 traces will be shown in the _Heap Details_ pane. |
| 57 |
| 58 [extension-link]: https://cs.chromium.org/chromium/src/third_party/catapult/expe
rimental/trace_on_tap/?q=traceontap+package:%5Echromium$&dr=CSs |
| 59 |
| 60 #### Native stack traces (Chromium - all OSes) |
| 61 |
| 62 On Linux / Android, you need to build Chromium with special flags to use native |
| 63 heap profiling. On macOS / Windows, it's also possible to use native heap |
| 64 profiling with Chromium. |
43 | 65 |
44 1. Build with the following GN flags: | 66 1. Build with the following GN flags: |
45 | 67 |
46 » Linux | 68 » macOS / Windows |
| 69 |
| 70 symbol_level = 1 |
| 71 |
| 72 Linux |
47 | 73 |
48 enable_profiling = true | 74 enable_profiling = true |
49 | 75 symbol_level = 1 |
50 | 76 |
51 Android | 77 Android |
52 | 78 |
53 arm_use_thumb = false | 79 arm_use_thumb = false |
54 enable_profiling = true | 80 enable_profiling = true |
| 81 symbol_level = 1 |
55 | 82 |
56 2. Start Chrome with `--enable-heap-profiling=native` switch (notice | 83 2. Start Chrome with `--enable-heap-profiling=native` switch (notice |
57 `=native` part). | 84 `=native` part). |
58 | 85 |
59 On Android use the command line tool before starting the app: | 86 On Android use the command line tool before starting the app: |
60 | 87 |
61 build/android/adb_chrome_public_command_line --enable-heap-profiling=nat
ive | 88 build/android/adb_chrome_public_command_line --enable-heap-profiling=nat
ive |
62 | 89 |
63 (run the tool with an empty argument `''` to clear the command line) | 90 (run the tool with an empty argument `''` to clear the command line) |
64 | 91 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 memory allocated by PartitionAlloc alone, the total renderer memory increase was | 186 memory allocated by PartitionAlloc alone, the total renderer memory increase was |
160 around 72 MiB.) | 187 around 72 MiB.) |
161 | 188 |
162 ![Diff of The Verge before and after loading ads][diff] | 189 ![Diff of The Verge before and after loading ads][diff] |
163 | 190 |
164 [pseudo-stack]: https://storage.googleapis.com/chromium-docs.appspot.
com/058e50350836f55724e100d4dbbddf4b9803f550 | 191 [pseudo-stack]: https://storage.googleapis.com/chromium-docs.appspot.
com/058e50350836f55724e100d4dbbddf4b9803f550 |
165 [break-down-by-backtrace]: https://storage.googleapis.com/chromium-docs.appspot.
com/ec61c5f15705f5bcf3ca83a155ed647a0538bbe1 | 192 [break-down-by-backtrace]: https://storage.googleapis.com/chromium-docs.appspot.
com/ec61c5f15705f5bcf3ca83a155ed647a0538bbe1 |
166 [break-down-by-type]: https://storage.googleapis.com/chromium-docs.appspot.
com/2236e61021922c0813908c6745136953fa20a37b | 193 [break-down-by-type]: https://storage.googleapis.com/chromium-docs.appspot.
com/2236e61021922c0813908c6745136953fa20a37b |
167 [type-then-backtrace]: https://storage.googleapis.com/chromium-docs.appspot.
com/c5367dde11476bdbf2d5a1c51674148915573d11 | 194 [type-then-backtrace]: https://storage.googleapis.com/chromium-docs.appspot.
com/c5367dde11476bdbf2d5a1c51674148915573d11 |
168 [diff]: https://storage.googleapis.com/chromium-docs.appspot.
com/802141906869cd533bb613da5f91bd0b071ceb24 | 195 [diff]: https://storage.googleapis.com/chromium-docs.appspot.
com/802141906869cd533bb613da5f91bd0b071ceb24 |
OLD | NEW |