Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2264)

Unified Diff: base/trace_event/malloc_dump_provider.cc

Issue 1877313003: [tracing] Track number of allocations in heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix indentation. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..be6efc866a363810bc87057b180624b61c1fabd1 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -178,21 +178,24 @@ 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, AllocationMetrics> 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_) {
+ AllocationMetrics& metrics = metrics_by_context[alloc_size.context];
+ metrics.size += alloc_size.size;
+ metrics.count++;
+ }
}
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));
}

Powered by Google App Engine
This is Rietveld 408576698