[tracing] Fix malloc accounting in memory-infra
Currently the malloc dump provider is reporting the total virtual
size as official "size" (the one plotted in the tracks) and the
allocated_objects as a child.
This is not fully correct, as the heap is not always necessarily
used and, more importantly, creates some funky behavior when
discounting the trace overehad.
This change moves the outer heap size to its own property, so that
the actual |uordblocks| becomes the size plotted on the track.
BUG=495628,467112
Review URL: https://codereview.chromium.org/1191893002
Cr-Commit-Position: refs/heads/master@{#334812}
CrOS-Libchrome-Original-Commit: db8a28cf1603950a2dedda3329d01285a3e317cd
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index 92d513f..3e593b0 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -32,13 +32,13 @@
struct mallinfo info = mallinfo();
DCHECK_GE(info.arena + info.hblkhd, info.uordblks);
- // When the system allocator is implemented by tcmalloc, the total physical
+ // When the system allocator is implemented by tcmalloc, the total heap
// size is given by |arena| and |hblkhd| is 0. In case of Android's jemalloc
// |arena| is 0 and the outer pages size is reported by |hblkhd|. In case of
// dlmalloc the total is given by |arena| + |hblkhd|.
// For more details see link: http://goo.gl/fMR8lF.
MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc");
- outer_dump->AddScalar(MemoryAllocatorDump::kNameSize,
+ outer_dump->AddScalar("heap_virtual_size",
MemoryAllocatorDump::kUnitsBytes,
info.arena + info.hblkhd);