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 <unordered_map> |
| 10 |
9 #include "base/allocator/allocator_extension.h" | 11 #include "base/allocator/allocator_extension.h" |
10 #include "base/allocator/allocator_shim.h" | 12 #include "base/allocator/allocator_shim.h" |
11 #include "base/allocator/features.h" | 13 #include "base/allocator/features.h" |
12 #include "base/debug/profiler.h" | 14 #include "base/debug/profiler.h" |
13 #include "base/trace_event/heap_profiler_allocation_context.h" | 15 #include "base/trace_event/heap_profiler_allocation_context.h" |
14 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 16 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
15 #include "base/trace_event/heap_profiler_allocation_register.h" | 17 #include "base/trace_event/heap_profiler_allocation_register.h" |
16 #include "base/trace_event/heap_profiler_heap_dump_writer.h" | 18 #include "base/trace_event/heap_profiler_heap_dump_writer.h" |
17 #include "base/trace_event/process_memory_dump.h" | 19 #include "base/trace_event/process_memory_dump.h" |
18 #include "base/trace_event/trace_event_argument.h" | 20 #include "base/trace_event/trace_event_argument.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested. | 291 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested. |
290 // However, when enabled, the overhead of the heap profiler should be always | 292 // However, when enabled, the overhead of the heap profiler should be always |
291 // reported to avoid oscillations of the malloc total in LIGHT dumps. | 293 // reported to avoid oscillations of the malloc total in LIGHT dumps. |
292 | 294 |
293 tid_dumping_heap_ = PlatformThread::CurrentId(); | 295 tid_dumping_heap_ = PlatformThread::CurrentId(); |
294 // At this point the Insert/RemoveAllocation hooks will ignore this thread. | 296 // 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 | 297 // 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. | 298 // profiler does not see unabalanced malloc/free calls from these containers. |
297 { | 299 { |
298 TraceEventMemoryOverhead overhead; | 300 TraceEventMemoryOverhead overhead; |
299 hash_map<AllocationContext, AllocationMetrics> metrics_by_context; | 301 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context; |
300 { | 302 { |
301 AutoLock lock(allocation_register_lock_); | 303 AutoLock lock(allocation_register_lock_); |
302 if (allocation_register_) { | 304 if (allocation_register_) { |
303 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | 305 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
304 for (const auto& alloc_size : *allocation_register_) { | 306 for (const auto& alloc_size : *allocation_register_) { |
305 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; | 307 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; |
306 metrics.size += alloc_size.size; | 308 metrics.size += alloc_size.size; |
307 metrics.count++; | 309 metrics.count++; |
308 } | 310 } |
309 } | 311 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 tid_dumping_heap_ == PlatformThread::CurrentId()) | 371 tid_dumping_heap_ == PlatformThread::CurrentId()) |
370 return; | 372 return; |
371 AutoLock lock(allocation_register_lock_); | 373 AutoLock lock(allocation_register_lock_); |
372 if (!allocation_register_) | 374 if (!allocation_register_) |
373 return; | 375 return; |
374 allocation_register_->Remove(address); | 376 allocation_register_->Remove(address); |
375 } | 377 } |
376 | 378 |
377 } // namespace trace_event | 379 } // namespace trace_event |
378 } // namespace base | 380 } // namespace base |
OLD | NEW |