| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/process_memory_dump.h" | 5 #include "base/trace_event/process_memory_dump.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 mad = CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); | 212 mad = CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); |
| 213 mad->set_flags(MemoryAllocatorDump::Flags::WEAK); | 213 mad->set_flags(MemoryAllocatorDump::Flags::WEAK); |
| 214 return mad; | 214 return mad; |
| 215 } | 215 } |
| 216 | 216 |
| 217 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( | 217 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( |
| 218 const MemoryAllocatorDumpGuid& guid) const { | 218 const MemoryAllocatorDumpGuid& guid) const { |
| 219 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); | 219 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, | |
| 223 std::unique_ptr<TracedValue> heap_dump) { | |
| 224 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); | |
| 225 heap_dumps_[absolute_name] = std::move(heap_dump); | |
| 226 } | |
| 227 | |
| 228 void ProcessMemoryDump::DumpHeapUsage( | 222 void ProcessMemoryDump::DumpHeapUsage( |
| 229 const base::hash_map<base::trace_event::AllocationContext, | 223 const base::hash_map<base::trace_event::AllocationContext, |
| 230 base::trace_event::AllocationMetrics>& metrics_by_context, | 224 base::trace_event::AllocationMetrics>& metrics_by_context, |
| 231 base::trace_event::TraceEventMemoryOverhead& overhead, | 225 base::trace_event::TraceEventMemoryOverhead& overhead, |
| 232 const char* allocator_name) { | 226 const char* allocator_name) { |
| 233 if (!metrics_by_context.empty()) { | 227 if (!metrics_by_context.empty()) { |
| 228 DCHECK_EQ(0ul, heap_dumps_.count(allocator_name)); |
| 234 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( | 229 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( |
| 235 metrics_by_context, *session_state()); | 230 metrics_by_context, *session_state()); |
| 236 AddHeapDump(allocator_name, std::move(heap_dump)); | 231 heap_dumps_[allocator_name] = std::move(heap_dump); |
| 237 } | 232 } |
| 238 | 233 |
| 239 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", | 234 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", |
| 240 allocator_name); | 235 allocator_name); |
| 241 overhead.DumpInto(base_name.c_str(), this); | 236 overhead.DumpInto(base_name.c_str(), this); |
| 242 } | 237 } |
| 243 | 238 |
| 244 void ProcessMemoryDump::Clear() { | 239 void ProcessMemoryDump::Clear() { |
| 245 if (has_process_totals_) { | 240 if (has_process_totals_) { |
| 246 process_totals_.Clear(); | 241 process_totals_.Clear(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 328 |
| 334 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, | 329 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, |
| 335 const std::string& target_node_name) { | 330 const std::string& target_node_name) { |
| 336 std::string child_mad_name = target_node_name + "/__" + source.ToString(); | 331 std::string child_mad_name = target_node_name + "/__" + source.ToString(); |
| 337 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); | 332 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); |
| 338 AddOwnershipEdge(source, target_child_mad->guid()); | 333 AddOwnershipEdge(source, target_child_mad->guid()); |
| 339 } | 334 } |
| 340 | 335 |
| 341 } // namespace trace_event | 336 } // namespace trace_event |
| 342 } // namespace base | 337 } // namespace base |
| OLD | NEW |