linux pprof工具安装,google perftools工具介绍
安装编译工具
sudo yum -y install gcc make
sudo yum -y install gcc gcc-c++
安装libunwind
wget https://github.com/libunwind/libunwind/archive/v0.99.tar.gz
tar -xvf v0.99.tar.gz
cd libunwind-0.99
autoreconf --force -v --install
./configure
make
make install
安装perftools
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.6.1/gperftools-2.6.1.tar.gz
tar -xvf gperftools-2.6.1.tar.gz # 解压
./configure
make
make install
配置
在/etc/ld.so.conf.d目录下建立文件perftools.conf,文件内容为libunwind库所在目录,本文中安装时都未指定目录,默认为:
/usr/local/lib
执行使之生效:
sudo /sbin/ldconfig
perftools是通过Linux的LD_PRELOAD达到java应用程序运行时,当调用malloc时换用它的libtcmalloc.so,因此需要在运行程序之前设置变量:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
export HEAPPROFILE=/root/perftools/java
产生报告
启动Java程序之后,会在HEAPPROFILE目录生成heap文件,运行如下命令,产生文本格式的报告:
pprof --text /usr/java/jdk1.8.0_91/bin/java java_31242.0001.heap
安装编译工具 sudo yum -y install gcc make sudo yum -y install gcc gcc-c++ 安装libunwind wget https://github.com/libunwind/libunwind/archive/v0.99.tar.gz tar -xvf v0.99.tar.gz cd libunwind-0.99 autoreconf --force -v --install ./configure make make install 安装perftools wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.6.1/gperftools-2.6.1.tar.gz tar -xvf gperftools-2.6.1.tar.gz # 解压 ./configure make make install 配置 在/etc/ld.so.conf.d目录下建立文件perftools.conf,文件内容为libunwind库所在目录,本文中安装时都未指定目录,默认为: /usr/local/lib 执行使之生效: sudo /sbin/ldconfig perftools是通过Linux的LD_PRELOAD达到java应用程序运行时,当调用malloc时换用它的libtcmalloc.so,因此需要在运行程序之前设置变量: export LD_PRELOAD=/usr/local/lib/libtcmalloc.so export HEAPPROFILE=/root/perftools/java 产生报告 启动Java程序之后,会在HEAPPROFILE目录生成heap文件,运行如下命令,产生文本格式的报告: pprof --text /usr/java/jdk1.8.0_91/bin/java java_31242.0001.heap