Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: base/trace_event/malloc_dump_provider.cc

Issue 2743563004: Stop reporting metadata_fragmentation_caches for macOS. (Closed)
Patch Set: nit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 DCHECK(res); 209 DCHECK(res);
210 res = allocator::GetNumericProperty("generic.current_allocated_bytes", 210 res = allocator::GetNumericProperty("generic.current_allocated_bytes",
211 &allocated_objects_size); 211 &allocated_objects_size);
212 DCHECK(res); 212 DCHECK(res);
213 #elif defined(OS_MACOSX) || defined(OS_IOS) 213 #elif defined(OS_MACOSX) || defined(OS_IOS)
214 malloc_statistics_t stats = {0}; 214 malloc_statistics_t stats = {0};
215 malloc_zone_statistics(nullptr, &stats); 215 malloc_zone_statistics(nullptr, &stats);
216 total_virtual_size = stats.size_allocated; 216 total_virtual_size = stats.size_allocated;
217 allocated_objects_size = stats.size_in_use; 217 allocated_objects_size = stats.size_in_use;
218 218
219 // The resident size is approximated to the max size in use, which would count 219 // Resident size is approximated pretty well by stats.max_size_in_use.
220 // the total size of all regions other than the free bytes at the end of each 220 // However, on macOS, freed blocks are both resident and reusable, which is
221 // region. In each allocation region the allocations are rounded off to a 221 // semantically equivalent to deallocated. The implementation of libmalloc
222 // fixed quantum, so the excess region will not be resident. 222 // will also only hold a fixed number of freed regions before actually
223 // See crrev.com/1531463004 for detailed explanation. 223 // starting to deallocate them, so stats.max_size_in_use is also not
224 resident_size = stats.max_size_in_use; 224 // representative of the peak size. As a result, stats.max_size_in_use is
225 // typically somewhere between actually resident [non-reusable] pages, and
226 // peak size. This is not very useful, so we just use stats.size_in_use for
227 // resident_size, even though it's an underestimate and fails to account for
228 // fragmentation. See
229 // https://bugs.chromium.org/p/chromium/issues/detail?id=695263#c1.
230 resident_size = stats.size_in_use;
225 #elif defined(OS_WIN) 231 #elif defined(OS_WIN)
226 WinHeapInfo main_heap_info = {}; 232 WinHeapInfo main_heap_info = {};
227 WinHeapMemoryDumpImpl(&main_heap_info); 233 WinHeapMemoryDumpImpl(&main_heap_info);
228 total_virtual_size = 234 total_virtual_size =
229 main_heap_info.committed_size + main_heap_info.uncommitted_size; 235 main_heap_info.committed_size + main_heap_info.uncommitted_size;
230 // Resident size is approximated with committed heap size. Note that it is 236 // Resident size is approximated with committed heap size. Note that it is
231 // possible to do this with better accuracy on windows by intersecting the 237 // possible to do this with better accuracy on windows by intersecting the
232 // working set with the virtual memory ranges occuipied by the heap. It's not 238 // working set with the virtual memory ranges occuipied by the heap. It's not
233 // clear that this is worth it, as it's fairly expensive to do. 239 // clear that this is worth it, as it's fairly expensive to do.
234 resident_size = main_heap_info.committed_size; 240 resident_size = main_heap_info.committed_size;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 tid_dumping_heap_ == PlatformThread::CurrentId()) 369 tid_dumping_heap_ == PlatformThread::CurrentId())
364 return; 370 return;
365 AutoLock lock(allocation_register_lock_); 371 AutoLock lock(allocation_register_lock_);
366 if (!allocation_register_) 372 if (!allocation_register_)
367 return; 373 return;
368 allocation_register_->Remove(address); 374 allocation_register_->Remove(address);
369 } 375 }
370 376
371 } // namespace trace_event 377 } // namespace trace_event
372 } // namespace base 378 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698