| Index: base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| index 49a235051c0731fd930bd7a897fc793cb867ab40..fc5da0d1dde9ed15498e1d03574d737c5f004460 100644
|
| --- a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| +++ b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| @@ -11,6 +11,7 @@
|
| #include <utility>
|
|
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/trace_event/memory_usage_estimator.h"
|
| #include "base/trace_event/trace_event_argument.h"
|
| #include "base/trace_event/trace_event_memory_overhead.h"
|
|
|
| @@ -23,6 +24,10 @@ StackFrameDeduplicator::FrameNode::FrameNode(StackFrame frame,
|
| StackFrameDeduplicator::FrameNode::FrameNode(const FrameNode& other) = default;
|
| StackFrameDeduplicator::FrameNode::~FrameNode() {}
|
|
|
| +size_t StackFrameDeduplicator::FrameNode::EstimateMemoryUsage() const {
|
| + return base::trace_event::EstimateMemoryUsage(children);
|
| +}
|
| +
|
| StackFrameDeduplicator::StackFrameDeduplicator() {}
|
| StackFrameDeduplicator::~StackFrameDeduplicator() {}
|
|
|
| @@ -116,19 +121,10 @@ void StackFrameDeduplicator::AppendAsTraceFormat(std::string* out) const {
|
|
|
| void StackFrameDeduplicator::EstimateTraceMemoryOverhead(
|
| TraceEventMemoryOverhead* overhead) {
|
| - // The sizes here are only estimates; they fail to take into account the
|
| - // overhead of the tree nodes for the map, but as an estimate this should be
|
| - // fine.
|
| - size_t maps_size = roots_.size() * sizeof(std::pair<StackFrame, int>);
|
| - size_t frames_allocated = frames_.capacity() * sizeof(FrameNode);
|
| - size_t frames_resident = frames_.size() * sizeof(FrameNode);
|
| -
|
| - for (const FrameNode& node : frames_)
|
| - maps_size += node.children.size() * sizeof(std::pair<StackFrame, int>);
|
| -
|
| + size_t memory_usage =
|
| + EstimateMemoryUsage(frames_) + EstimateMemoryUsage(roots_);
|
| overhead->Add("StackFrameDeduplicator",
|
| - sizeof(StackFrameDeduplicator) + maps_size + frames_allocated,
|
| - sizeof(StackFrameDeduplicator) + maps_size + frames_resident);
|
| + sizeof(StackFrameDeduplicator) + memory_usage);
|
| }
|
|
|
| } // namespace trace_event
|
|
|