| 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/heap/BlinkGCMemoryDumpProvider.h" | 5 #include "platform/heap/BlinkGCMemoryDumpProvider.h" |
| 6 | 6 |
| 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 8 #include "base/trace_event/heap_profiler_allocation_register.h" | 8 #include "base/trace_event/heap_profiler_allocation_register.h" |
| 9 #include "base/trace_event/trace_event_memory_overhead.h" | 9 #include "base/trace_event/trace_event_memory_overhead.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 { | 57 { |
| 58 // In the case of a detailed dump perform a mark-only GC pass to collect | 58 // In the case of a detailed dump perform a mark-only GC pass to collect |
| 59 // more detailed stats. | 59 // more detailed stats. |
| 60 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) | 60 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) |
| 61 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::Take
Snapshot, BlinkGC::ForcedGC); | 61 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::Take
Snapshot, BlinkGC::ForcedGC); |
| 62 dumpMemoryTotals(memoryDump); | 62 dumpMemoryTotals(memoryDump); |
| 63 | 63 |
| 64 if (m_isHeapProfilingEnabled) { | 64 if (m_isHeapProfilingEnabled) { |
| 65 // Overhead should always be reported, regardless of light vs. heavy. | 65 // Overhead should always be reported, regardless of light vs. heavy. |
| 66 base::trace_event::TraceEventMemoryOverhead overhead; | 66 base::trace_event::TraceEventMemoryOverhead overhead; |
| 67 base::hash_map<base::trace_event::AllocationContext, size_t> bytesByCont
ext; | 67 base::hash_map<base::trace_event::AllocationContext, base::trace_event::
AllocationMetrics> metricsByContext; |
| 68 { | 68 { |
| 69 MutexLocker locker(m_allocationRegisterMutex); | 69 MutexLocker locker(m_allocationRegisterMutex); |
| 70 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { | 70 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { |
| 71 for (const auto& allocSize : *m_allocationRegister) | 71 for (const auto& allocSize : *m_allocationRegister) { |
| 72 bytesByContext[allocSize.context] += allocSize.size; | 72 base::trace_event::AllocationMetrics& metrics = metricsByCon
text[allocSize.context]; |
| 73 metrics.size += allocSize.size; |
| 74 metrics.count++; |
| 75 } |
| 73 } | 76 } |
| 74 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); | 77 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); |
| 75 } | 78 } |
| 76 memoryDump->dumpHeapUsage(bytesByContext, overhead, "blink_gc"); | 79 memoryDump->dumpHeapUsage(metricsByContext, overhead, "blink_gc"); |
| 77 } | 80 } |
| 78 | 81 |
| 79 // Merge all dumps collected by ThreadHeap::collectGarbage. | 82 // Merge all dumps collected by ThreadHeap::collectGarbage. |
| 80 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) | 83 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) |
| 81 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); | 84 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); |
| 82 return true; | 85 return true; |
| 83 } | 86 } |
| 84 | 87 |
| 85 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled) | 88 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled) |
| 86 { | 89 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 128 } |
| 126 | 129 |
| 127 void BlinkGCMemoryDumpProvider::remove(Address address) | 130 void BlinkGCMemoryDumpProvider::remove(Address address) |
| 128 { | 131 { |
| 129 MutexLocker locker(m_allocationRegisterMutex); | 132 MutexLocker locker(m_allocationRegisterMutex); |
| 130 if (m_allocationRegister) | 133 if (m_allocationRegister) |
| 131 m_allocationRegister->Remove(address); | 134 m_allocationRegister->Remove(address); |
| 132 } | 135 } |
| 133 | 136 |
| 134 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |