How is it possible to use C++ STL containers with jemalloc (or any other malloc
implementation)?
Is it as simple as include jemalloc/jemalloc.h
If you want to replace malloc
everywhere in your program (which I wanted to and also seems the only logical solution), then all you have to do is link against it.
So, if you use gcc
then all you have to do is:
g++ yourprogram.cpp -ljemalloc
But, if it's not possible, then you have to use jemalloc
via another functions e.g. je_malloc
and je_free
, and then you have to overload the new
and delete
operators.
There's no need for including any header if you don't use implementation-specific features (statistics, mostly).