Implicit malloc/free replacement on windows/MSVC

Jason Evans jasone at canonware.com
Mon Sep 29 15:21:04 PDT 2014


On Sep 24, 2014, at 2:04 AM, David Rigby <daver at couchbase.com> wrote:
> I’m investigating replacing our application's existing memory allocator (tcmalloc) with jemalloc, mainly due to jemalloc’s “lowest possible address” policy which facilities some application-level reallocation of long-lived objects to reduce heap fragmentation.
> 
> The integration on Linux and OS X is working nicely, however I’ve come to Windows and I’ve hit a bit of an impasse in dealing with indirect uses of malloc (e.g. strdup()), and I wonder if anyone has any ideas.
> 
> [...]
> 
> The only solutions I can find to this are either:
> 
> (A) runtime-patching the various CRT functions to jump to the custom allocators versions - as implemented by tcmalloc [3].
> (B) building a custom version of the CRT with the memory allocation functions removed, and statically linking this into the application - as implemented by mozilla [4].
> 
> Does anyone know of a “third way” to solve this? 
> 
> If not, I think the tcmalloc runtime-patching is fractionally the lesser of the two evils - would the list (Jason?) consider accepting a patch which ported that functionality to jemalloc? It’s written in C++ which may be undesirable, but it’s Windows only at least…

I'd love to have the the tcmalloc-esque run-time patching mechanism in jemalloc, but since I don't use Windows much, it hasn't been a burning enough issue for me to do the work.  A patch would be very welcome.

Thanks,
Jason


More information about the jemalloc-discuss mailing list