summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/trace_event/process_memory_dump.cc18
-rw-r--r--base/trace_event/process_memory_dump.h7
2 files changed, 22 insertions, 3 deletions
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 4390905..7ce117a 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -27,12 +27,24 @@ ProcessMemoryDump::~ProcessMemoryDump() {
MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
const std::string& absolute_name) {
MemoryAllocatorDump* mad = new MemoryAllocatorDump(absolute_name, this);
- DCHECK_EQ(0ul, allocator_dumps_.count(absolute_name));
- allocator_dumps_storage_.push_back(mad);
- allocator_dumps_[absolute_name] = mad;
+ AddAllocatorDumpInternal(mad); // Takes ownership of |mad|.
+ return mad;
+}
+
+MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
+ const std::string& absolute_name,
+ const MemoryAllocatorDumpGuid& guid) {
+ MemoryAllocatorDump* mad = new MemoryAllocatorDump(absolute_name, this, guid);
+ AddAllocatorDumpInternal(mad); // Takes ownership of |mad|.
return mad;
}
+void ProcessMemoryDump::AddAllocatorDumpInternal(MemoryAllocatorDump* mad) {
+ DCHECK_EQ(0ul, allocator_dumps_.count(mad->absolute_name()));
+ allocator_dumps_storage_.push_back(mad);
+ allocator_dumps_[mad->absolute_name()] = mad;
+}
+
MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
const std::string& absolute_name) const {
auto it = allocator_dumps_.find(absolute_name);
diff --git a/base/trace_event/process_memory_dump.h b/base/trace_event/process_memory_dump.h
index 55d7871..7b1434b 100644
--- a/base/trace_event/process_memory_dump.h
+++ b/base/trace_event/process_memory_dump.h
@@ -78,8 +78,13 @@ class BASE_EXPORT ProcessMemoryDump {
// by this provider. It is possible to specify nesting by using a
// path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2).
// Leading or trailing slashes are not allowed.
+ // guid: an optional identifier, unique among all processes within the
+ // scope of a global dump. This is only relevant when using
+ // AddOwnershipEdge(). If omitted, it will be automatically generated.
// ProcessMemoryDump handles the memory ownership of its MemoryAllocatorDumps.
MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name);
+ MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name,
+ const MemoryAllocatorDumpGuid& guid);
// Looks up a MemoryAllocatorDump given its allocator and heap names, or
// nullptr if not found.
@@ -108,6 +113,8 @@ class BASE_EXPORT ProcessMemoryDump {
}
private:
+ void AddAllocatorDumpInternal(MemoryAllocatorDump* mad);
+
ProcessMemoryTotals process_totals_;
bool has_process_totals_;