性能排查工具

Java

详述文档:
https://docs.oracle.com/en/java/javase/11/troubleshoot/general-java-troubleshooting.html

jps

jstat

jstat -gcutil 4969 1s

1
2
3
4
5
6
7
8
9
10
11
12
13
$ jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

jconsole

jvisualvm

jmc

jstack

Java堆栈查看工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Usage:
jstack [-l] <pid>
(to connect to running process)
jstack -F [-m] [-l] <pid>
(to connect to a hung process)
jstack [-m] [-l] <executable> <core>
(to connect to a core file)
jstack [-m] [-l] [server_id@]<remote server IP or hostname>
(to connect to a remote debug server)

Options:
-F to force a thread dump. Use when jstack <pid> does not respond (process is hung)
-m to print both java and native frames (mixed mode)
-l long listing. Prints additional information about locks
-h or -help to print this help message

jmap

1
2
3
4
5
6
7
8
9
#查看动态链接库
jmap 10828
#查看内存统计信息
jmap -heap 10828
#查看内存中对象统计信息
jmap -histo 10828
jmap -histo:live 10828
#Dump内存供其他工具分析(jhat/mat)
jmap -dump:format=b,file=dump.bin 10828

jhat

Java内存分析工具

jjs/jrunscript

Nashorn脚本运行工具,jjs为交互式,jrunscript为命令式

jcmd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Print full HotSpot and JDK version ID
jcmd <process id/main class> VM.version
#Print all the system properties set for a VM
jcmd <process id/main class> VM.system_properties
#Print all the flags used for a VM
jcmd <process id/main class> VM.flags
#Print the uptime in seconds
jcmd <process id/main class> VM.uptime
#Create a class histogram
jcmd <process id/main class> GC.class_histogram
#Create a heap dump (hprof dump)
jcmd GC.heap_dump filename=Myheapdump
#Create a heap histogram
jcmd <process id/main class> GC.class_histogram filename=Myheaphistogram
#Print all threads with stack traces
jcmd <process id/main class> Thread.print
#Start a recording
jcmd 7060 JFR.start name=MyRecording settings=profile delay=20s duration=2m filename=C:\TEMP\myrecording.jfr
#Check a recording
jcmd 7060 JFR.check
#Stop a recording
jcmd 7060 JFR.stop
#Dump a recording
jcmd 7060 JFR.dump name=MyRecording filename=C:\TEMP\myrecording.jfr

Linux

ps

uptime

top

sar

iostat

mpstat

pidstat

vmstat

netstat

ss

iftop

grep

tail

find

awk