安装

1
2
3
4
5
6
7
8
9
10
11
12
13
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz

tar zxvf gperftools-2.7.tar.gz

cd gperftools-2.7

./configure --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc --enable-minimal
make
sudo make install

sudo ln -s /usr/local/lib/libtcmalloc_minimal.so /usr/local/lib/libtcmalloc.so
sudo ln -s /usr/local/lib/libtcmalloc_minimal.so.4 /usr/local/lib/libtcmalloc.so.4
sudo ln -s /usr/local/lib/libtcmalloc_minimal.so.4.5.3 /usr/local/lib/libtcmalloc.so.4.5.3

使用

代码不需要修改,仅需要链接相应库即可 -ltcmalloc