#1067·gperftools

use tcmalloc explicitly without overriding system malloc/free

Author: sillykelvinCreated Nov 19, 2018Updated Mar 17, 2026
Labelstrivial-to-contributealk-wants-this-soon

In our application, we want malloc/free calls using system ones(it's glibc here), and when we want to use tcmalloc, we can call tc_malloc/tc_free explicitly. However, after we linked to tcmalloc with -ltcmalloc_minimal, it seems all malloc/free have been replaced.

I searched with google but nothing useful found, is there any way to achieve this?

EDIT: We are using a Linux box with kernel version 3.10, glibc version 2.17, gcc version 4.8.5, and tcmalloc is compiled with --enable-minimal flag, and is statically linked into our program.