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

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

Issue 2163783003: Implement a ScopedThreadHeapUsage class to allow profiling per-thread heap usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim-default
Patch Set: Address Nico's comments. Created 4 years, 3 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 | « base/debug/scoped_thread_heap_usage_unittest.cc ('k') | 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return ptr; 70 return ptr;
71 } 71 }
72 72
73 void HookFree(const AllocatorDispatch* self, void* address) { 73 void HookFree(const AllocatorDispatch* self, void* address) {
74 if (address) 74 if (address)
75 MallocDumpProvider::GetInstance()->RemoveAllocation(address); 75 MallocDumpProvider::GetInstance()->RemoveAllocation(address);
76 const AllocatorDispatch* const next = self->next; 76 const AllocatorDispatch* const next = self->next;
77 next->free_function(next, address); 77 next->free_function(next, address);
78 } 78 }
79 79
80 size_t HookGetSizeEstimate(const AllocatorDispatch* self, void* address) {
81 const AllocatorDispatch* const next = self->next;
82 return next->get_size_estimate_function(next, address);
83 }
84
80 AllocatorDispatch g_allocator_hooks = { 85 AllocatorDispatch g_allocator_hooks = {
81 &HookAlloc, /* alloc_function */ 86 &HookAlloc, /* alloc_function */
82 &HookZeroInitAlloc, /* alloc_zero_initialized_function */ 87 &HookZeroInitAlloc, /* alloc_zero_initialized_function */
83 &HookllocAligned, /* alloc_aligned_function */ 88 &HookllocAligned, /* alloc_aligned_function */
84 &HookRealloc, /* realloc_function */ 89 &HookRealloc, /* realloc_function */
85 &HookFree, /* free_function */ 90 &HookFree, /* free_function */
86 nullptr, /* next */ 91 &HookGetSizeEstimate, /* get_size_estimate_function */
92 nullptr, /* next */
87 }; 93 };
88 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) 94 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
89 95
90 #if defined(OS_WIN) 96 #if defined(OS_WIN)
91 // A structure containing some information about a given heap. 97 // A structure containing some information about a given heap.
92 struct WinHeapInfo { 98 struct WinHeapInfo {
93 HANDLE heap_id; 99 HANDLE heap_id;
94 size_t committed_size; 100 size_t committed_size;
95 size_t uncommitted_size; 101 size_t uncommitted_size;
96 size_t allocated_size; 102 size_t allocated_size;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 tid_dumping_heap_ == PlatformThread::CurrentId()) 357 tid_dumping_heap_ == PlatformThread::CurrentId())
352 return; 358 return;
353 AutoLock lock(allocation_register_lock_); 359 AutoLock lock(allocation_register_lock_);
354 if (!allocation_register_) 360 if (!allocation_register_)
355 return; 361 return;
356 allocation_register_->Remove(address); 362 allocation_register_->Remove(address);
357 } 363 }
358 364
359 } // namespace trace_event 365 } // namespace trace_event
360 } // namespace base 366 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/scoped_thread_heap_usage_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698