| 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 "base/trace_event/heap_profiler_allocation_context.h" | 7 #include "base/trace_event/heap_profiler_allocation_context.h" |
| 8 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 8 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 9 #include "base/trace_event/heap_profiler_allocation_register.h" | 9 #include "base/trace_event/heap_profiler_allocation_register.h" |
| 10 #include "base/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 { | 105 { |
| 106 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ()); | 106 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ()); |
| 107 return &instance; | 107 return &instance; |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l
evelOfDetail, WebProcessMemoryDump* memoryDump) | 110 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l
evelOfDetail, WebProcessMemoryDump* memoryDump) |
| 111 { | 111 { |
| 112 if (m_isHeapProfilingEnabled) { | 112 if (m_isHeapProfilingEnabled) { |
| 113 // Overhead should always be reported, regardless of light vs. heavy. | 113 // Overhead should always be reported, regardless of light vs. heavy. |
| 114 base::trace_event::TraceEventMemoryOverhead overhead; | 114 base::trace_event::TraceEventMemoryOverhead overhead; |
| 115 base::hash_map<base::trace_event::AllocationContext, size_t> bytesByCont
ext; | 115 base::hash_map<base::trace_event::AllocationContext, base::trace_event::
AllocationMetrics> metricsByContext; |
| 116 { | 116 { |
| 117 MutexLocker locker(m_allocationRegisterMutex); | 117 MutexLocker locker(m_allocationRegisterMutex); |
| 118 // Dump only the overhead estimation in non-detailed dumps. | 118 // Dump only the overhead estimation in non-detailed dumps. |
| 119 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { | 119 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { |
| 120 for (const auto& allocSize : *m_allocationRegister) | 120 for (const auto& allocSize : *m_allocationRegister) { |
| 121 bytesByContext[allocSize.context] += allocSize.size; | 121 base::trace_event::AllocationMetrics& metrics = metricsByCon
text[allocSize.context]; |
| 122 metrics.size += allocSize.size; |
| 123 metrics.count++; |
| 124 } |
| 122 } | 125 } |
| 123 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); | 126 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); |
| 124 } | 127 } |
| 125 memoryDump->dumpHeapUsage(bytesByContext, overhead, "partition_alloc"); | 128 memoryDump->dumpHeapUsage(metricsByContext, overhead, "partition_alloc")
; |
| 126 } | 129 } |
| 127 | 130 |
| 128 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); | 131 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); |
| 129 | 132 |
| 130 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu
mp( | 133 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu
mp( |
| 131 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); | 134 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); |
| 132 | 135 |
| 133 // This method calls memoryStats.partitionsDumpBucketStats with memory stati
stics. | 136 // This method calls memoryStats.partitionsDumpBucketStats with memory stati
stics. |
| 134 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail
::Light, &partitionStatsDumper); | 137 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail
::Light, &partitionStatsDumper); |
| 135 | 138 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 181 } |
| 179 | 182 |
| 180 void PartitionAllocMemoryDumpProvider::remove(void* address) | 183 void PartitionAllocMemoryDumpProvider::remove(void* address) |
| 181 { | 184 { |
| 182 MutexLocker locker(m_allocationRegisterMutex); | 185 MutexLocker locker(m_allocationRegisterMutex); |
| 183 if (m_allocationRegister) | 186 if (m_allocationRegister) |
| 184 m_allocationRegister->Remove(address); | 187 m_allocationRegister->Remove(address); |
| 185 } | 188 } |
| 186 | 189 |
| 187 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |