Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3130)

Unified Diff: base/trace_event/malloc_dump_provider.cc

Issue 2777343003: [memory-infra] Add api to enable heap profiling in MemoryDumpManager
Patch Set: nits. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/malloc_dump_provider.cc
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index 7f2706092ee6f7aafc8283ca22e67bad13022c3c..8a902422345fa05e236a7da81136b0f0e26ed094 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -286,9 +286,11 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
return true;
// The dumps of the heap profiler should be created only when heap profiling
- // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested.
- // However, when enabled, the overhead of the heap profiler should be always
- // reported to avoid oscillations of the malloc total in LIGHT dumps.
+ // was enabled with any mode AND a DETAILED dump is requested or heap
+ // profiling was enabled with BACKGROUND mode AND BACKGROUND dump is
+ // requested. However, when enabled, the overhead of the heap profiler should
+ // be always reported to avoid oscillations of the malloc total in LIGHT
+ // dumps.
tid_dumping_heap_ = PlatformThread::CurrentId();
// At this point the Insert/RemoveAllocation hooks will ignore this thread.
@@ -300,7 +302,10 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
{
AutoLock lock(allocation_register_lock_);
if (allocation_register_) {
- if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
+ if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED ||
+ (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND &&
+ AllocationContextTracker::capture_mode() ==
+ AllocationContextTracker::CaptureMode::BACKGROUND)) {
for (const auto& alloc_size : *allocation_register_) {
AllocationMetrics& metrics = metrics_by_context[alloc_size.context];
metrics.size += alloc_size.size;
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context_tracker.cc ('k') | base/trace_event/memory_dump_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698