mzhaom / gperftools

Fast, multi-threaded malloc() and nifty performance analysis tools
https://code.google.com/p/gperftools/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Changes to enable WIN32 allocator overrides #125

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With Chrome, we'd like to build by overriding 
malloc/free/realloc/calloc/new/delete/msize/etc.

This patch adds a new macro WIN32_OVERRIDE_ALLOCATORS which supports this.

Also add a check for _HAS_EXCEPTIONS=0; when building without exceptions we 
don't want the exception handling logic in the operator new.

Original issue reported on code.google.com by mbel...@chromium.org on 14 Apr 2009 at 9:06

GoogleCodeExporter commented 9 years ago
Here is an updated patch.  I had left out one file.

Original comment by mbel...@chromium.org on 14 Apr 2009 at 9:15

GoogleCodeExporter commented 9 years ago
One more try!

Original comment by mbel...@chromium.org on 14 Apr 2009 at 9:20

Attachments:

GoogleCodeExporter commented 9 years ago
Can you explain this patch a little?  You say this:
+/* define this if you are linking tcmalloc statically and overriding the
+ * default allocators.

But as far as I can tell, none of this is needed when linking tcmalloc 
statically? 
In the .sln provided with perftools, we link tcmalloc_minimal_unittest 
statically and
it all works as-is, without the need for this undef.

I believe we still want to patch windows functions, even when linking in 
libtcmalloc
statically.  The application may still have libcrt somewhere else, right?

} +// These routines relate to overriding allocators statically linked
} +// on Windows when using the VS2005 libcmt.lib.
} +// See the documentation for instructions on how to link tcmalloc this way.

I believe these belong in patch_functions.cc and not in tcmalloc.cc.  Or 
perhaps they
belong in another, totally new file in the src/windows directory.  I'm trying to
really limit the number of #ifdefs in tcmalloc.cc.  I also would love it if you 
had a
complete list of functions to patch/override (do we need to override 
_malloc_dbg, for
instance?) even if we don't deal with them in this patch.

Original comment by csilv...@gmail.com on 14 Apr 2009 at 9:29

GoogleCodeExporter commented 9 years ago

Original comment by csilv...@gmail.com on 15 Apr 2009 at 2:04

GoogleCodeExporter commented 9 years ago
This functionality has been added to perftools 1.2, just released.

Original comment by csilv...@gmail.com on 18 Apr 2009 at 12:14

GoogleCodeExporter commented 9 years ago
A description on how to use the new approach is given in:
http://groups.google.com/group/google-perftools/browse_thread/thread/41cd3710af8
5e57b

Original comment by weidenri...@gmx.de on 12 May 2009 at 10:14