(工具) TCMalloc笔记

下载及编译

wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz
tar xvf gperftools-2.9.1.tar.gz && cd gperftools-2.9.1

../configure --prefix=/usr/local/lib --disable-heap-checker --disable-debugalloc --enable-minimal # --disable-cpu-profiler --disable-heap-profiler 
make && make install

tcmalloc使用

  1. 静态链接:在编译选项的最后加入 /usr/local/lib/libtcmalloc_minimal.a 即可链接静态库
  2. 动态链接:在编译选项这里插入 -L/usr/local/lib -ltcmalloc_minimal 即可;
  3. 重启进程即可使用:启动进程前执行 export LD_PRELOAD=/usr/local/lib/libtcmalloc_minimal.so即可;

tcmalloc原理:

posted @ 2022-02-28 15:23  山岚2013  阅读(63)  评论(0编辑  收藏  举报