| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 outer_dump->AddScalar("virtual_size", MemoryAllocatorDump::kUnitsBytes, | 242 outer_dump->AddScalar("virtual_size", MemoryAllocatorDump::kUnitsBytes, |
| 243 total_virtual_size); | 243 total_virtual_size); |
| 244 outer_dump->AddScalar(MemoryAllocatorDump::kNameSize, | 244 outer_dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 245 MemoryAllocatorDump::kUnitsBytes, resident_size); | 245 MemoryAllocatorDump::kUnitsBytes, resident_size); |
| 246 | 246 |
| 247 MemoryAllocatorDump* inner_dump = pmd->CreateAllocatorDump(kAllocatedObjects); | 247 MemoryAllocatorDump* inner_dump = pmd->CreateAllocatorDump(kAllocatedObjects); |
| 248 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize, | 248 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 249 MemoryAllocatorDump::kUnitsBytes, | 249 MemoryAllocatorDump::kUnitsBytes, |
| 250 allocated_objects_size); | 250 allocated_objects_size); |
| 251 if (allocated_objects_count != 0) { | 251 if (allocated_objects_count != 0) { |
| 252 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize, | 252 inner_dump->AddScalar(MemoryAllocatorDump::kNameObjectCount, |
| 253 MemoryAllocatorDump::kUnitsObjects, | 253 MemoryAllocatorDump::kUnitsObjects, |
| 254 allocated_objects_count); | 254 allocated_objects_count); |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (resident_size - allocated_objects_size > 0) { | 257 if (resident_size > allocated_objects_size) { |
| 258 // Explicitly specify why is extra memory resident. In tcmalloc it accounts | 258 // Explicitly specify why is extra memory resident. In tcmalloc it accounts |
| 259 // for free lists and caches. In mac and ios it accounts for the | 259 // for free lists and caches. In mac and ios it accounts for the |
| 260 // fragmentation and metadata. | 260 // fragmentation and metadata. |
| 261 MemoryAllocatorDump* other_dump = | 261 MemoryAllocatorDump* other_dump = |
| 262 pmd->CreateAllocatorDump("malloc/metadata_fragmentation_caches"); | 262 pmd->CreateAllocatorDump("malloc/metadata_fragmentation_caches"); |
| 263 other_dump->AddScalar(MemoryAllocatorDump::kNameSize, | 263 other_dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 264 MemoryAllocatorDump::kUnitsBytes, | 264 MemoryAllocatorDump::kUnitsBytes, |
| 265 resident_size - allocated_objects_size); | 265 resident_size - allocated_objects_size); |
| 266 } | 266 } |
| 267 | 267 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 tid_dumping_heap_ == PlatformThread::CurrentId()) | 350 tid_dumping_heap_ == PlatformThread::CurrentId()) |
| 351 return; | 351 return; |
| 352 AutoLock lock(allocation_register_lock_); | 352 AutoLock lock(allocation_register_lock_); |
| 353 if (!allocation_register_) | 353 if (!allocation_register_) |
| 354 return; | 354 return; |
| 355 allocation_register_->Remove(address); | 355 allocation_register_->Remove(address); |
| 356 } | 356 } |
| 357 | 357 |
| 358 } // namespace trace_event | 358 } // namespace trace_event |
| 359 } // namespace base | 359 } // namespace base |
| OLD | NEW |