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