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

Side by Side Diff: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Address comments (heaps_v2) 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 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 "platform/PartitionAllocMemoryDumpProvider.h" 5 #include "platform/PartitionAllocMemoryDumpProvider.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/heap_profiler_allocation_context.h" 8 #include "base/trace_event/heap_profiler_allocation_context.h"
9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
10 #include "base/trace_event/heap_profiler_allocation_register.h" 10 #include "base/trace_event/heap_profiler_allocation_register.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return &instance; 124 return &instance;
125 } 125 }
126 126
127 bool PartitionAllocMemoryDumpProvider::OnMemoryDump( 127 bool PartitionAllocMemoryDumpProvider::OnMemoryDump(
128 const base::trace_event::MemoryDumpArgs& args, 128 const base::trace_event::MemoryDumpArgs& args,
129 base::trace_event::ProcessMemoryDump* memoryDump) { 129 base::trace_event::ProcessMemoryDump* memoryDump) {
130 using base::trace_event::MemoryDumpLevelOfDetail; 130 using base::trace_event::MemoryDumpLevelOfDetail;
131 131
132 MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail; 132 MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail;
133 if (m_isHeapProfilingEnabled) { 133 if (m_isHeapProfilingEnabled) {
134 // Overhead should always be reported, regardless of light vs. heavy. 134 MutexLocker locker(m_allocationRegisterMutex);
135 base::trace_event::TraceEventMemoryOverhead overhead; 135 memoryDump->DumpHeapUsage(*m_allocationRegister, kPartitionAllocDumpName);
136 base::hash_map<base::trace_event::AllocationContext,
137 base::trace_event::AllocationMetrics>
138 metricsByContext;
139 {
140 MutexLocker locker(m_allocationRegisterMutex);
141 // Dump only the overhead estimation in non-detailed dumps.
142 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED) {
143 for (const auto& allocSize : *m_allocationRegister) {
144 base::trace_event::AllocationMetrics& metrics =
145 metricsByContext[allocSize.context];
146 metrics.size += allocSize.size;
147 metrics.count++;
148 }
149 }
150 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
151 }
152 memoryDump->DumpHeapUsage(metricsByContext, overhead, "partition_alloc");
153 } 136 }
154 137
155 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); 138 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
156 139
157 base::trace_event::MemoryAllocatorDump* partitionsDump = 140 base::trace_event::MemoryAllocatorDump* partitionsDump =
158 memoryDump->CreateAllocatorDump(base::StringPrintf( 141 memoryDump->CreateAllocatorDump(base::StringPrintf(
159 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); 142 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
160 143
161 // This method calls memoryStats.partitionsDumpBucketStats with memory 144 // This method calls memoryStats.partitionsDumpBucketStats with memory
162 // statistics. 145 // statistics.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 m_allocationRegister->Insert(address, size, context); 195 m_allocationRegister->Insert(address, size, context);
213 } 196 }
214 197
215 void PartitionAllocMemoryDumpProvider::remove(void* address) { 198 void PartitionAllocMemoryDumpProvider::remove(void* address) {
216 MutexLocker locker(m_allocationRegisterMutex); 199 MutexLocker locker(m_allocationRegisterMutex);
217 if (m_allocationRegister) 200 if (m_allocationRegister)
218 m_allocationRegister->Remove(address); 201 m_allocationRegister->Remove(address);
219 } 202 }
220 203
221 } // namespace blink 204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698