google-perftools是一个堆外内存分析工具.
sudo yum -y install gcc make
sudo yum -y install gcc gcc-c++
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-beta.tar.gz
./configure --prefix=/data0/java/deploy/google-perftools/local/libunwind
make
make install
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz
./configure --prefix=/data0/java/deploy/google-perftools/local/gperftools-2.5/
make
make install
vi /etc/ld.so.conf.d/usr_local_lib.conf
/data0/java/deploy/google-perftools/local/libunwind/lib
:wq! #保存退出
sudo /sbin/ldconfig #执行此命令,使libunwind生效。 需要sudo权限
在应用程序启动前加入:
export LD_PRELOAD=/data0/java/deploy/google-perftools/local/gperftools-2.5/lib/libtcmalloc.so
export HEAPPROFILE=/data0/java/deploy/google-perftools/local/gzip
local/gperftools-2.5/bin/pprof --text /usr/local/java/jdk1.7.0_55/bin/java test.0132.heap
然后查看分析结果如下
作者:Tyorofurin
链接:https://www.jianshu.com/p/309c9f61d495
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。