| 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/malloc_dump_provider.h" | 5 #include "base/trace_event/malloc_dump_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 10 #include "base/allocator/allocator_shim.h" | 10 #include "base/allocator/allocator_shim.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | 185 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
| 186 for (const auto& alloc_size : *allocation_register_) { | 186 for (const auto& alloc_size : *allocation_register_) { |
| 187 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; | 187 AllocationMetrics& metrics = metrics_by_context[alloc_size.context]; |
| 188 metrics.size += alloc_size.size; | 188 metrics.size += alloc_size.size; |
| 189 metrics.count++; | 189 metrics.count++; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 allocation_register_->EstimateTraceMemoryOverhead(&overhead); | 192 allocation_register_->EstimateTraceMemoryOverhead(&overhead); |
| 193 } | 193 } |
| 194 } // lock(allocation_register_lock_) | 194 } // lock(allocation_register_lock_) |
| 195 | 195 pmd->DumpHeapUsage(metrics_by_context, overhead, "malloc"); |
| 196 if (!metrics_by_context.empty()) { | |
| 197 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( | |
| 198 metrics_by_context, *pmd->session_state()); | |
| 199 pmd->AddHeapDump("malloc", std::move(heap_dump)); | |
| 200 } | |
| 201 overhead.DumpInto("tracing/heap_profiler_malloc", pmd); | |
| 202 } | 196 } |
| 203 tid_dumping_heap_ = kInvalidThreadId; | 197 tid_dumping_heap_ = kInvalidThreadId; |
| 204 | 198 |
| 205 return true; | 199 return true; |
| 206 } | 200 } |
| 207 | 201 |
| 208 void MallocDumpProvider::OnHeapProfilingEnabled(bool enabled) { | 202 void MallocDumpProvider::OnHeapProfilingEnabled(bool enabled) { |
| 209 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | 203 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) |
| 210 if (enabled) { | 204 if (enabled) { |
| 211 { | 205 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 tid_dumping_heap_ == PlatformThread::CurrentId()) | 248 tid_dumping_heap_ == PlatformThread::CurrentId()) |
| 255 return; | 249 return; |
| 256 AutoLock lock(allocation_register_lock_); | 250 AutoLock lock(allocation_register_lock_); |
| 257 if (!allocation_register_) | 251 if (!allocation_register_) |
| 258 return; | 252 return; |
| 259 allocation_register_->Remove(address); | 253 allocation_register_->Remove(address); |
| 260 } | 254 } |
| 261 | 255 |
| 262 } // namespace trace_event | 256 } // namespace trace_event |
| 263 } // namespace base | 257 } // namespace base |
| OLD | NEW |