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 "base/trace_event/heap_profiler_allocation_register.h" | 5 #include "base/trace_event/heap_profiler_allocation_register.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/trace_event/trace_event_memory_overhead.h" | 10 #include "base/trace_event/trace_event_memory_overhead.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 AllocationRegister::ConstIterator AllocationRegister::end() const { | 151 AllocationRegister::ConstIterator AllocationRegister::end() const { |
152 return ConstIterator(*this, AllocationMap::kInvalidKVIndex); | 152 return ConstIterator(*this, AllocationMap::kInvalidKVIndex); |
153 } | 153 } |
154 | 154 |
155 void AllocationRegister::EstimateTraceMemoryOverhead( | 155 void AllocationRegister::EstimateTraceMemoryOverhead( |
156 TraceEventMemoryOverhead* overhead) const { | 156 TraceEventMemoryOverhead* overhead) const { |
157 size_t allocated = sizeof(AllocationRegister); | 157 size_t allocated = sizeof(AllocationRegister); |
158 size_t resident = sizeof(AllocationRegister) + | 158 size_t resident = sizeof(AllocationRegister) + |
159 allocations_.EstimateUsedMemory() + | 159 allocations_.EstimateUsedMemory() + |
160 backtraces_.EstimateUsedMemory(); | 160 backtraces_.EstimateUsedMemory(); |
161 overhead->Add("AllocationRegister", allocated, resident); | 161 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerAllocationRegister, |
| 162 allocated, resident); |
162 } | 163 } |
163 | 164 |
164 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace( | 165 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace( |
165 const Backtrace& backtrace) { | 166 const Backtrace& backtrace) { |
166 auto index = backtraces_.Insert(backtrace, 0).first; | 167 auto index = backtraces_.Insert(backtrace, 0).first; |
167 if (index == BacktraceMap::kInvalidKVIndex) | 168 if (index == BacktraceMap::kInvalidKVIndex) |
168 return kOutOfStorageBacktraceIndex; | 169 return kOutOfStorageBacktraceIndex; |
169 auto& backtrace_and_count = backtraces_.Get(index); | 170 auto& backtrace_and_count = backtraces_.Get(index); |
170 backtrace_and_count.second++; | 171 backtrace_and_count.second++; |
171 return index; | 172 return index; |
(...skipping 13 matching lines...) Expand all Loading... |
185 const auto& address_and_info = allocations_.Get(index); | 186 const auto& address_and_info = allocations_.Get(index); |
186 const auto& backtrace_and_count = | 187 const auto& backtrace_and_count = |
187 backtraces_.Get(address_and_info.second.backtrace_index); | 188 backtraces_.Get(address_and_info.second.backtrace_index); |
188 return {address_and_info.first, address_and_info.second.size, | 189 return {address_and_info.first, address_and_info.second.size, |
189 AllocationContext(backtrace_and_count.first, | 190 AllocationContext(backtrace_and_count.first, |
190 address_and_info.second.type_name)}; | 191 address_and_info.second.type_name)}; |
191 } | 192 } |
192 | 193 |
193 } // namespace trace_event | 194 } // namespace trace_event |
194 } // namespace base | 195 } // namespace base |
OLD | NEW |