I'm linking my C++ program to tcmalloc with -ltcmalloc_minimal in linux and i have install the ltcmalloc lib with apt-get install libgoogle-perftools-dev.
Do i need to add any include file to my project source files to enable tcmalloc in my project? Do tcmalloc replaces all the new/free/malloc in all libs used by my project?
Unless you specifically call tcmalloc API - i.e tc_new, tc_free You don't need to include any headers from tcmalloc. This is because malloc and other memory functions declarations are already included by the call to include <malloc.h>. Their definitions are overridden(or aliased) in tcmalloc library. In TCMalloc, the standard API (new, malloc, realloc, free, delete, etc...) and also POSIX API (such as posix_memaligned) are either aliased (in GCC compatible platforms) or overridden (windows, ...). The only thing you need to add is in case of static linkage the libraries -ltcmalloc_minimal.a or -ltcmalloc.a and it's path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With