tree: 8f1f6562aa33d05eeded239c429563a5671d8b0e [path history] [tgz]
  1. BUILD.gn
  2. DEPS
  3. OWNERS
  4. README.md
  5. address.h
  6. allocation_event.cc
  7. allocation_event.h
  8. allocation_tracker.cc
  9. allocation_tracker.h
  10. backtrace.cc
  11. backtrace.h
  12. backtrace_storage.cc
  13. backtrace_storage.h
  14. backtrace_storage_unittest.cc
  15. json_exporter.cc
  16. json_exporter.h
  17. json_exporter_unittest.cc
  18. memlog_connection_manager.cc
  19. memlog_connection_manager.h
  20. memlog_receiver.h
  21. memlog_receiver_pipe.cc
  22. memlog_receiver_pipe.h
  23. memlog_receiver_pipe_posix.cc
  24. memlog_receiver_pipe_posix.h
  25. memlog_receiver_pipe_win.cc
  26. memlog_receiver_pipe_win.h
  27. memlog_stream_parser.cc
  28. memlog_stream_parser.h
  29. memlog_stream_parser_unittest.cc
  30. memlog_stream_receiver.h
  31. profiling_browsertest.cc
  32. profiling_manifest.json
  33. profiling_service.cc
  34. profiling_service.h
chrome/profiling/README.md

chrome/profiling

This document describes the architecture for the profiling process, which tracks memory allocations in other processes. See design doc for more details.

There is some additional information in //chrome/common/profiling/README.md

How To Enable Out of Process Heap Profiling

Navigate to chrome://flags/#memlog and set the flag to “Profile only the browser process.” It's possible to profile all processes, but that has a higher performance impact, and heap dumps of renderer processes are less actionable.

How To Use Out of Process Heap Profiling

By default, you don‘t need to do anything. The heap profiler will detect when the browser’s memory usage has exceeded a certain threshold and upload a trace.

To force an upload, or to create a heap dump manually, see chrome://memory-internals. The resulting heap dump is intended to be used with symbolize_trace and diff_heap_profiler.py.

It's also possible to view the heap dump within a memory-infra trace, although the results will still need to be symbolized with symbolize_trace.

Due to size constraints, most allocations are pruned from the heap dump. Only allocations of sufficient size and/or frequency are kept. After pruning, the result is ~100x smaller, but still accounts for about half of all allocations. More importantly, it still accounts for all obvious memory leaks.

Communication Model

When profiling is enabled, the browser process will spawn the profiling service. The services lives in a sandboxed, utility process, and its interface is at chrome/common/profiling/memlog_service.mojom.

All other processes, including the browser process, are ProfilingClients. See profiling_client.mojom. Depending on the profiling mode, the browser process will start profiling for just itself and the GPU process [--memlog=minimal], or itself and all child processes [--memlog=all].

The browser process creates a pipe for each ProfilingClient that allows the client processes to communicate memory events to the profiling process.

Code Locations

//chrome/common/profiling - Logic for MemlogClient. //chrome/browser/profiling_host - Logic in browser process for starting profiling service, and connecting MemlogClients to the profiling service. //chrome/profiling - Profiling service.