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

Unified Diff: base/allocator/allocator_extension.h

Issue 1665553002: metrics: Connect leak detector to allocator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: primiano's feedback; Register observer sooner Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/allocator/allocator_extension.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/allocator_extension.h
diff --git a/base/allocator/allocator_extension.h b/base/allocator/allocator_extension.h
index 64bfd1cc4acaa3fe2a8fc1e8f80ab1fe674f3856..9f2775a427fa73de1ca221eb7d646209b048b271 100644
--- a/base/allocator/allocator_extension.h
+++ b/base/allocator/allocator_extension.h
@@ -13,6 +13,10 @@
namespace base {
namespace allocator {
+// Callback types for alloc and free.
+using AllocHookFunc = void (*)(const void*, size_t);
+using FreeHookFunc = void (*)(const void*);
+
// Request that the allocator release any free memory it knows about to the
// system.
BASE_EXPORT void ReleaseFreeMemory();
@@ -25,6 +29,22 @@ BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
BASE_EXPORT bool IsHeapProfilerRunning();
+// Register callbacks for alloc and free. Can only store one callback at a time
+// for each of alloc and free.
+BASE_EXPORT void SetHooks(AllocHookFunc alloc_hook, FreeHookFunc free_hook);
+
+// Attempts to unwind the call stack from the current location where this
+// function is being called from. Must be called from a hook function registered
+// by calling SetSingle{Alloc,Free}Hook, directly or indirectly.
+//
+// Arguments:
+// stack: pointer to a pre-allocated array of void*'s.
+// max_stack_size: indicates the size of the array in |stack|.
+//
+// Returns the number of call stack frames stored in |stack|, or 0 if no call
+// stack information is available.
+BASE_EXPORT int GetCallStack(void** stack, int max_stack_size);
+
} // namespace allocator
} // namespace base
« no previous file with comments | « no previous file | base/allocator/allocator_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698