Skip to main content



TCMalloc (google-perftools) 是用于优化C++写的多线程应用,比glibc 2.3的malloc快。这个模块可以用来让MySQL在高并发下内存占用更加稳定。


The glibc built-in stack-unwinder on 64-bit systems has some problems with the perftools libraries. (In particular, the cpu/heap profiler may be in the middle of malloc, holding some malloc-related locks when they invoke the stack unwinder. The built-in stack unwinder may call malloc recursively, which may require the thread to acquire a lock it already holds: deadlock.)

For that reason, if you use a 64-bit system, we strongly recommend you install libunwind before trying to configure or install gperftools. libunwind can be found at here

Even if you already have libunwind installed, you should check the version. Versions older than this will not work properly; too-new versions introduce new code that does not work well with perftools (because libunwind can call malloc, which will lead to deadlock).

# wget
# tar xvf libunwind-0.99-beta.tar.gz
# cd libunwind
# ./configure
# make && make install

# wget
# tar xvf gperftools-2.0.tar.gz
# cd gperftools
# ./configure
# make && make install


打开mysqld_safe脚本 (默认在/usr/bin/mysqld_safe)


# service mysql restart