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 = |