| OLD | NEW |
| 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 <unordered_map> | 7 #include <unordered_map> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 10 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return &instance; | 128 return &instance; |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool PartitionAllocMemoryDumpProvider::OnMemoryDump( | 131 bool PartitionAllocMemoryDumpProvider::OnMemoryDump( |
| 132 const base::trace_event::MemoryDumpArgs& args, | 132 const base::trace_event::MemoryDumpArgs& args, |
| 133 base::trace_event::ProcessMemoryDump* memory_dump) { | 133 base::trace_event::ProcessMemoryDump* memory_dump) { |
| 134 using base::trace_event::MemoryDumpLevelOfDetail; | 134 using base::trace_event::MemoryDumpLevelOfDetail; |
| 135 | 135 |
| 136 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail; | 136 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail; |
| 137 if (allocation_register_.is_enabled()) { | 137 if (allocation_register_.is_enabled()) { |
| 138 // Overhead should always be reported, regardless of light vs. heavy. | 138 memory_dump->DumpHeapUsage(allocation_register_, kPartitionAllocDumpName); |
| 139 base::trace_event::TraceEventMemoryOverhead overhead; | |
| 140 std::unordered_map<base::trace_event::AllocationContext, | |
| 141 base::trace_event::AllocationMetrics> | |
| 142 metrics_by_context; | |
| 143 // Dump only the overhead estimation in non-detailed dumps. | |
| 144 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | |
| 145 allocation_register_.UpdateAndReturnsMetrics(metrics_by_context); | |
| 146 } | |
| 147 allocation_register_.EstimateTraceMemoryOverhead(&overhead); | |
| 148 memory_dump->DumpHeapUsage(metrics_by_context, overhead, "partition_alloc"); | |
| 149 } | 139 } |
| 150 | 140 |
| 151 PartitionStatsDumperImpl partition_stats_dumper(memory_dump, level_of_detail); | 141 PartitionStatsDumperImpl partition_stats_dumper(memory_dump, level_of_detail); |
| 152 | 142 |
| 153 base::trace_event::MemoryAllocatorDump* partitions_dump = | 143 base::trace_event::MemoryAllocatorDump* partitions_dump = |
| 154 memory_dump->CreateAllocatorDump(base::StringPrintf( | 144 memory_dump->CreateAllocatorDump(base::StringPrintf( |
| 155 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); | 145 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); |
| 156 | 146 |
| 157 // This method calls memoryStats.partitionsDumpBucketStats with memory | 147 // This method calls memoryStats.partitionsDumpBucketStats with memory |
| 158 // statistics. | 148 // statistics. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 allocation_register_.Insert(address, size, context); | 193 allocation_register_.Insert(address, size, context); |
| 204 } | 194 } |
| 205 | 195 |
| 206 void PartitionAllocMemoryDumpProvider::Remove(void* address) { | 196 void PartitionAllocMemoryDumpProvider::Remove(void* address) { |
| 207 if (!allocation_register_.is_enabled()) | 197 if (!allocation_register_.is_enabled()) |
| 208 return; | 198 return; |
| 209 allocation_register_.Remove(address); | 199 allocation_register_.Remove(address); |
| 210 } | 200 } |
| 211 | 201 |
| 212 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |