buffer8848 / gperftools

Automatically exported from code.google.com/p/gperftools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes to enable WIN32 allocator overrides

GoogleCodeExporter opened this issue · comments

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

Here is an updated patch.  I had left out one file.

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

One more try!

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

Attachments:

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

  • Changed state: Accepted
  • Added labels: Priority-Medium, Type-Patch

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

  • Changed state: Started
This functionality has been added to perftools 1.2, just released.

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

  • Changed state: Fixed
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