diff options
author | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2008-12-13 01:35:42 +0000 |
---|---|---|
committer | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2008-12-13 01:35:42 +0000 |
commit | 6fa2a2574ce1c15ac12293e24691d69a41972e54 (patch) | |
tree | 606da4a80de5c91721969ade70c4d9a87cb1604a /src/google/malloc_hook.h | |
parent | 16191f87ff8dc78295c0f617060460664fc444bd (diff) | |
download | gperftools-6fa2a2574ce1c15ac12293e24691d69a41972e54.tar.gz |
Thu Dec 11 16:01:32 2008 Google Inc. <opensource@google.com>
* google-perftools: version 1.0rc1 release
* Replace API for selectively disabling heap-checker in code (sanjay)
* Add a pre-mmap hook (daven, adlr)
* Add MallocExtension interface to set memory-releasing rate (fikes)
* Augment pprof to allow any string ending in /pprof/profile (csilvers)
* PORTING: Rewrite -- and fix -- malloc patching for windows (dvitek)
* PORTING: Add nm-pdb and addr2line-pdb for use by pprof (dvitek)
* PORTING: Improve cygwin and mingw support (jperkins, csilvers)
* PORTING: Fix pprof for mac os x, other pprof improvements (csilvers)
* PORTING: Fix some PPC bugs in our locking code (anton.blanchard)
* A new unittest, smapling_test, to verify tcmalloc-profiles (csilvers)
* Turn off TLS for gcc < 4.1.2, due to a TLS + -fPIC bug (csilvers)
* Prefer __builtin_frame_address to assembly for stacktraces (nlewycky)
* Separate tcmalloc.cc out into multiple files -- finally! (kash)
* Make our locking code work with -fPIC on 32-bit x86 (aruns)
* Fix an initialization-ordering bug for tcmalloc/profiling (csilvers)
* Use "initial exec" model of TLS to speed up tcmalloc (csilvers)
* Enforce 16-byte alignment for tcmalloc, for SSE (sanjay)
git-svn-id: http://gperftools.googlecode.com/svn/trunk@60 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/google/malloc_hook.h')
-rw-r--r-- | src/google/malloc_hook.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/google/malloc_hook.h b/src/google/malloc_hook.h index 88d3e77..f2713e9 100644 --- a/src/google/malloc_hook.h +++ b/src/google/malloc_hook.h @@ -74,7 +74,7 @@ extern "C" { // Annoying stuff for windows -- makes sure clients can import these functions #ifndef PERFTOOLS_DLL_DECL -# ifdef WIN32 +# ifdef _WIN32 # define PERFTOOLS_DLL_DECL __declspec(dllimport) # else # define PERFTOOLS_DLL_DECL @@ -106,6 +106,22 @@ class PERFTOOLS_DLL_DECL MallocHook { } inline static void InvokeDeleteHook(const void* p); + // The PreMmapHook is invoked with mmap or mmap64 arguments just + // before the call is actually made. Such a hook may be useful + // in memory limited contexts, to catch allocations that will exceed + // a memory limit, and take outside actions to increase that limit. + typedef MallocHook_PreMmapHook PreMmapHook; + inline static PreMmapHook GetPreMmapHook(); + inline static PreMmapHook SetPreMmapHook(PreMmapHook hook) { + return MallocHook_SetPreMmapHook(hook); + } + inline static void InvokePreMmapHook(const void* start, + size_t size, + int protection, + int flags, + int fd, + off_t offset); + // The MmapHook is invoked whenever a region of memory is mapped. // It may be passed MAP_FAILED if the mmap failed. typedef MallocHook_MmapHook MmapHook; @@ -142,6 +158,19 @@ class PERFTOOLS_DLL_DECL MallocHook { int flags, const void* new_addr); + // The PreSbrkHook is invoked just before sbrk is called -- except when + // the increment is 0. This is because sbrk(0) is often called + // to get the top of the memory stack, and is not actually a + // memory-allocation call. It may be useful in memory-limited contexts, + // to catch allocations that will exceed the limit and take outside + // actions to increase such a limit. + typedef MallocHook_PreSbrkHook PreSbrkHook; + inline static PreSbrkHook GetPreSbrkHook(); + inline static PreSbrkHook SetPreSbrkHook(PreSbrkHook hook) { + return MallocHook_SetPreSbrkHook(hook); + } + inline static void InvokePreSbrkHook(ptrdiff_t increment); + // The SbrkHook is invoked whenever sbrk is called -- except when // the increment is 0. This is because sbrk(0) is often called // to get the top of the memory stack, and is not actually a |