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

Unified Diff: base/debug/thread_heap_usage_tracker.cc

Issue 2658723007: Hook up allocator shim on mac. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/debug/thread_heap_usage_tracker.cc
diff --git a/base/debug/thread_heap_usage_tracker.cc b/base/debug/thread_heap_usage_tracker.cc
index 25af20b0aa7d20ecdfa04af0bda3d6d0ab2eb884..accd1b3ab9eb59edf43d685a6f5a5d43ad33d73a 100644
--- a/base/debug/thread_heap_usage_tracker.cc
+++ b/base/debug/thread_heap_usage_tracker.cc
@@ -130,10 +130,34 @@ size_t GetSizeEstimateFn(const AllocatorDispatch* self, void* address) {
return self->next->get_size_estimate_function(self->next, address);
}
+unsigned BatchMallocFn(const AllocatorDispatch* self,
+ size_t size,
+ void** results,
+ unsigned num_requested) {
+ unsigned count = self->next->batch_malloc_function(self->next, size, results,
+ num_requested);
+ for (unsigned i = 0; i < count; ++i) {
+ RecordAlloc(self->next, results[i], size);
+ }
+ return count;
+}
+
+void BatchFreeFn(const AllocatorDispatch* self,
+ void** to_be_freed,
+ unsigned num_to_be_freed) {
+ for (unsigned i = 0; i < num_to_be_freed; ++i) {
+ if (to_be_freed[i] != nullptr) {
+ RecordFree(self->next, to_be_freed[i]);
+ }
+ }
+ self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed);
+}
+
// The allocator dispatch used to intercept heap operations.
AllocatorDispatch allocator_dispatch = {
&AllocFn, &AllocZeroInitializedFn, &AllocAlignedFn, &ReallocFn,
- &FreeFn, &GetSizeEstimateFn, nullptr};
+ &FreeFn, &GetSizeEstimateFn, &BatchMallocFn, &BatchFreeFn,
+ nullptr};
ThreadHeapUsage* GetOrCreateThreadUsage() {
ThreadHeapUsage* allocator_usage =

Powered by Google App Engine
This is Rietveld 408576698