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/malloc_dump_provider.h" | 5 #include "base/trace_event/malloc_dump_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
10 #include "base/allocator/allocator_shim.h" | 10 #include "base/allocator/allocator_shim.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested. | 289 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested. |
290 // However, when enabled, the overhead of the heap profiler should be always | 290 // However, when enabled, the overhead of the heap profiler should be always |
291 // reported to avoid oscillations of the malloc total in LIGHT dumps. | 291 // reported to avoid oscillations of the malloc total in LIGHT dumps. |
292 | 292 |
293 tid_dumping_heap_ = PlatformThread::CurrentId(); | 293 tid_dumping_heap_ = PlatformThread::CurrentId(); |
294 // At this point the Insert/RemoveAllocation hooks will ignore this thread. | 294 // At this point the Insert/RemoveAllocation hooks will ignore this thread. |
295 // Enclosing all the temporariy data structures in a scope, so that the heap | 295 // Enclosing all the temporariy data structures in a scope, so that the heap |
296 // profiler does not see unabalanced malloc/free calls from these containers. | 296 // profiler does not see unabalanced malloc/free calls from these containers. |
297 { | 297 { |
298 TraceEventMemoryOverhead overhead; | 298 TraceEventMemoryOverhead overhead; |
299 hash_map<AllocationContext, AllocationMetrics> metrics_by_context; | 299 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context; |
Łukasz Anforowicz
2017/04/24 18:46:10
IWYU: #include <unordered_map> ? (I don't see suc
| |
300 { | 300 { |
301 AutoLock lock(allocation_register_lock_); | 301 AutoLock lock(allocation_register_lock_); |
302 if (allocation_register_) { | 302 if (allocation_register_) { |
303 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | 303 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
304 for (const auto& alloc_size : *allocation_register_) { | 304 for (const auto& alloc_size : *allocation_register_) { |
305 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; | 305 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; |
306 metrics.size += alloc_size.size; | 306 metrics.size += alloc_size.size; |
307 metrics.count++; | 307 metrics.count++; |
308 } | 308 } |
309 } | 309 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 tid_dumping_heap_ == PlatformThread::CurrentId()) | 369 tid_dumping_heap_ == PlatformThread::CurrentId()) |
370 return; | 370 return; |
371 AutoLock lock(allocation_register_lock_); | 371 AutoLock lock(allocation_register_lock_); |
372 if (!allocation_register_) | 372 if (!allocation_register_) |
373 return; | 373 return; |
374 allocation_register_->Remove(address); | 374 allocation_register_->Remove(address); |
375 } | 375 } |
376 | 376 |
377 } // namespace trace_event | 377 } // namespace trace_event |
378 } // namespace base | 378 } // namespace base |
OLD | NEW |