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

Unified Diff: base/trace_event/heap_profiler_stack_frame_deduplicator.cc

Issue 2514913002: [tracing] Use EstimateMemoryUsage() in deduplicators. (Closed)
Patch Set: git cl format Created 4 years, 1 month 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/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
« no previous file with comments | « base/trace_event/heap_profiler_stack_frame_deduplicator.h ('k') | base/trace_event/heap_profiler_type_name_deduplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698