| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 malloc_zone_statistics(nullptr, &stats); | 121 malloc_zone_statistics(nullptr, &stats); |
| 122 total_virtual_size = stats.size_allocated; | 122 total_virtual_size = stats.size_allocated; |
| 123 allocated_objects_size = stats.size_in_use; | 123 allocated_objects_size = stats.size_in_use; |
| 124 | 124 |
| 125 // The resident size is approximated to the max size in use, which would count | 125 // The resident size is approximated to the max size in use, which would count |
| 126 // the total size of all regions other than the free bytes at the end of each | 126 // the total size of all regions other than the free bytes at the end of each |
| 127 // region. In each allocation region the allocations are rounded off to a | 127 // region. In each allocation region the allocations are rounded off to a |
| 128 // fixed quantum, so the excess region will not be resident. | 128 // fixed quantum, so the excess region will not be resident. |
| 129 // See crrev.com/1531463004 for detailed explanation. | 129 // See crrev.com/1531463004 for detailed explanation. |
| 130 resident_size = stats.max_size_in_use; | 130 resident_size = stats.max_size_in_use; |
| 131 #elif defined(OS_WIN) |
| 132 // TODO(siggi): DO NOT SUBMIT |
| 133 // Walk the Windows heap backing the CRT allocation pool as is done in |
| 134 // winheap_dump_provider_win.cc or ideally share the code. |
| 131 #else | 135 #else |
| 132 struct mallinfo info = mallinfo(); | 136 struct mallinfo info = mallinfo(); |
| 133 DCHECK_GE(info.arena + info.hblkhd, info.uordblks); | 137 DCHECK_GE(info.arena + info.hblkhd, info.uordblks); |
| 134 | 138 |
| 135 // In case of Android's jemalloc |arena| is 0 and the outer pages size is | 139 // In case of Android's jemalloc |arena| is 0 and the outer pages size is |
| 136 // reported by |hblkhd|. In case of dlmalloc the total is given by | 140 // reported by |hblkhd|. In case of dlmalloc the total is given by |
| 137 // |arena| + |hblkhd|. For more details see link: http://goo.gl/fMR8lF. | 141 // |arena| + |hblkhd|. For more details see link: http://goo.gl/fMR8lF. |
| 138 total_virtual_size = info.arena + info.hblkhd; | 142 total_virtual_size = info.arena + info.hblkhd; |
| 139 resident_size = info.uordblks; | 143 resident_size = info.uordblks; |
| 140 allocated_objects_size = info.uordblks; | 144 allocated_objects_size = info.uordblks; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 tid_dumping_heap_ == PlatformThread::CurrentId()) | 252 tid_dumping_heap_ == PlatformThread::CurrentId()) |
| 249 return; | 253 return; |
| 250 AutoLock lock(allocation_register_lock_); | 254 AutoLock lock(allocation_register_lock_); |
| 251 if (!allocation_register_) | 255 if (!allocation_register_) |
| 252 return; | 256 return; |
| 253 allocation_register_->Remove(address); | 257 allocation_register_->Remove(address); |
| 254 } | 258 } |
| 255 | 259 |
| 256 } // namespace trace_event | 260 } // namespace trace_event |
| 257 } // namespace base | 261 } // namespace base |
| OLD | NEW |