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

Side by Side Diff: content/child/web_memory_dump_provider_adapter.cc

Issue 1494293005: [Tracing] Enable heap dumps with both type info and backtraces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sfdedup-iter
Patch Set: Address most primiano comments Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/web_memory_dump_provider_adapter.h" 5 #include "content/child/web_memory_dump_provider_adapter.h"
6 6
7 #include "base/containers/hash_tables.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
9 #include "base/trace_event/heap_profiler_allocation_context.h" 10 #include "base/trace_event/heap_profiler_allocation_context.h"
10 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 11 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
11 #include "base/trace_event/heap_profiler_allocation_register.h" 12 #include "base/trace_event/heap_profiler_allocation_register.h"
12 #include "base/trace_event/heap_profiler_heap_dump_writer.h" 13 #include "base/trace_event/heap_profiler_heap_dump_writer.h"
13 #include "base/trace_event/process_memory_dump.h" 14 #include "base/trace_event/process_memory_dump.h"
14 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
15 #include "base/trace_event/trace_event_memory_overhead.h" 16 #include "base/trace_event/trace_event_memory_overhead.h"
16 #include "content/child/web_process_memory_dump_impl.h" 17 #include "content/child/web_process_memory_dump_impl.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 break; 71 break;
71 default: 72 default:
72 NOTREACHED(); 73 NOTREACHED();
73 return false; 74 return false;
74 } 75 }
75 WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd); 76 WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd);
76 77
77 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED && 78 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED &&
78 web_memory_dump_provider_->supportsHeapProfiling() && 79 web_memory_dump_provider_->supportsHeapProfiling() &&
79 g_heap_profiling_enabled) { 80 g_heap_profiling_enabled) {
80 HeapDumpWriter writer(pmd->session_state()->stack_frame_deduplicator(),
81 pmd->session_state()->type_name_deduplicator());
82 TraceEventMemoryOverhead overhead; 81 TraceEventMemoryOverhead overhead;
83 82 base::hash_map<AllocationContext, size_t> allocations;
84 { 83 {
85 AutoLock lock(g_allocation_register_lock.Get()); 84 AutoLock lock(g_allocation_register_lock.Get());
86 for (const auto& alloc_size : *g_allocation_register) 85
87 writer.InsertAllocation(alloc_size.context, alloc_size.size); 86 for (const auto& allocation : *g_allocation_register)
87 allocations[allocation.context] += allocation.size;
88 88
89 g_allocation_register->EstimateTraceMemoryOverhead(&overhead); 89 g_allocation_register->EstimateTraceMemoryOverhead(&overhead);
90 } 90 }
91 91
92 pmd->AddHeapDump("partition_alloc", writer.WriteHeapDump()); 92 auto heap_dump = WriteHeapDump(
93 allocations, pmd->session_state()->stack_frame_deduplicator(),
94 pmd->session_state()->type_name_deduplicator());
95 pmd->AddHeapDump("partition_alloc", heap_dump);
93 overhead.DumpInto("tracing/heap_profiler", pmd); 96 overhead.DumpInto("tracing/heap_profiler", pmd);
94 } 97 }
95 98
96 return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl); 99 return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl);
97 } 100 }
98 101
99 void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) { 102 void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) {
100 if (!web_memory_dump_provider_->supportsHeapProfiling()) 103 if (!web_memory_dump_provider_->supportsHeapProfiling())
101 return; 104 return;
102 105
(...skipping 15 matching lines...) Expand all
118 web_memory_dump_provider_->onHeapProfilingEnabled(ReportAllocation, 121 web_memory_dump_provider_->onHeapProfilingEnabled(ReportAllocation,
119 ReportFree); 122 ReportFree);
120 } else { 123 } else {
121 web_memory_dump_provider_->onHeapProfilingEnabled(nullptr, nullptr); 124 web_memory_dump_provider_->onHeapProfilingEnabled(nullptr, nullptr);
122 } 125 }
123 126
124 g_heap_profiling_enabled = enabled; 127 g_heap_profiling_enabled = enabled;
125 } 128 }
126 129
127 } // namespace content 130 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698