1. 程式人生 > >Java效能分析

Java效能分析

匯出dump檔案

jmap -F -dump:format=b,file=tomcat.bin 9142(程序ID)

分析工具

使用Eclipse Memory Analyzer分析工具,下載地址:https://www.eclipse.org/mat/ 這個工具也很強大,詳細看幫助

將上面的專案.bin檔案開啟,即可如下:


直接使用jconsole工具連線本地或遠端程序,如圖


遠端連線需要,對遠端的java程序作附加變數設定,如:

java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Dcom.sun.management.jmxremote.port=50380 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &

其中(例子是沒有使用認證的):

-Dcom.sun.management.jmxremote.port=90380 指明jmx連線的埠

-Dcom.sun.management.jmxremote.authenticate=false  指明是否作連線認證,如果是內網可以不用認證

-Dcom.sun.management.jmxremote.ssl=false  是否使用ssl連線

-Dcom.sun.management.jmxremote.pwd.file=/data/app/jdk1.8.0_101/jre/lib/management/jmxremote.password 在認證模式下需要設定此檔案路徑