安装libunwind-dev

apt install libunwind-dev

拉取源代码

git clone https://github.com/gperftools/gperftools.git
./autogen.sh
./configure --enable-frame-pointers --enable-libunwind
make && make install
ldconfig
ln -sf /usr/local/lib/libtcmalloc* /usr/lib/

更新freenginx配置

mkdir /tmp/tcmalloc
chown -R www:www /tmp/tcmalloc
sed -i '/nginx.pid/a\
google_perftools_profiles /tmp/tcmalloc;' /usr/local/nginx/conf/nginx.conf

更新mysql my.cnf配置

[mysqld_safe]
malloc-lib=/usr/lib/libtcmalloc.so

检查生效

lsof -n |grep tcmalloc

标签: TCMalloc, gperftools

添加新评论