gperftools是Google提供的一套工具,其中的一个功能是CPU profiler,用于分析程序性能,找到程序的性能瓶颈。
1.安装libunwind库
可以从http://download.savannah.gnu.org/releases/libunwind下载相应的libunwind版本,这里下载的是libunwind-0.99-beta.tar.gz,安装过程如下
[root@localhost home]#tar zxvf libunwind-0.99-beta.tar.gz
[root@localhost home]# cd libunwind-0.99-beta/
[root@localhost libunwind-0.99-beta]#./configure
[root@localhost libunwind-0.99-beta]#make
[root@localhost libunwind-0.99-beta]#make install
[root@localhost libunwind-0.99-beta]#make clean
2.安装google-perftools
可以从https://github.com/gperftools/gperftools下载相应的google-perftools版本,这里下载的是google-perftools-2.5.tar.gz,安装过程如下:
[root@localhost home]# tar zxvf google-perftools-2.5.tar.gz
[root@localhost home]# cd google-perftools-2.5/
[root@localhost google-perftools-2.5]# ./configure
[root@localhost google-perftools-2.5]# make
[root@localhost google-perftools-2.5]# make install
[root@localhost google-perftools-2.5]# make clean
[root@localhost google-perftools-2.5]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
[root@localhost google-perftools-2.5]# ldconfig
至此,google-perftools安装完成。
3.为google-perftools添加线程目录
创建一个线程目录,这里将文件放在/tmp/tcmalloc下,操作如下:
[root@localhost home]#mkdir /tmp/tcmalloc
[root@localhost home]#chmod 0777 /tmp/tcmalloc
4.修改tomcat启动文件startup.sh
加入export LD_PRELOAD=/usr/local/l