Chromium Code Reviews| Index: base/trace_event/malloc_dump_provider.cc |
| diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc |
| index 17e5c1e62074f95720442ee3b49a944607b490bf..54322b7f616c5b4a270325b0739a550032846cea 100644 |
| --- a/base/trace_event/malloc_dump_provider.cc |
| +++ b/base/trace_event/malloc_dump_provider.cc |
| @@ -178,21 +178,23 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, |
| // profiler does not see unabalanced malloc/free calls from these containers. |
| { |
| TraceEventMemoryOverhead overhead; |
| - hash_map<AllocationContext, size_t> bytes_by_context; |
| + hash_map<AllocationContext, AllocationsSizeAndCount> metrics_by_context; |
| { |
| AutoLock lock(allocation_register_lock_); |
| if (allocation_register_) { |
| if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
| - for (const auto& alloc_size : *allocation_register_) |
| - bytes_by_context[alloc_size.context] += alloc_size.size; |
| + for (const auto& alloc_size : *allocation_register_) { |
| + metrics_by_context[alloc_size.context].size += alloc_size.size; |
| + metrics_by_context[alloc_size.context].count++; |
|
Dmitry Skiba
2016/04/14 19:07:30
Let's avoid second lookup by caching result from t
Primiano Tucci (use gerrit)
2016/04/14 19:37:21
+1. Good suggestion ;-)
ssid
2016/04/14 20:17:10
Done.
|
| + } |
| } |
| allocation_register_->EstimateTraceMemoryOverhead(&overhead); |
| } |
| } // lock(allocation_register_lock_) |
| - if (!bytes_by_context.empty()) { |
| + if (!metrics_by_context.empty()) { |
| std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( |
| - bytes_by_context, pmd->session_state()->stack_frame_deduplicator(), |
| + metrics_by_context, pmd->session_state()->stack_frame_deduplicator(), |
| pmd->session_state()->type_name_deduplicator()); |
| pmd->AddHeapDump("malloc", std::move(heap_dump)); |
| } |