JVM性能调优工具06-jstack-JVM线程栈分析工具

释放双眼,带上耳机,听听看~!

[超级链接:JVM性能调优工具学习记录-序章]


本章主要学习JVM线程栈分析工具jstack。

1.用途

打印JVM线程栈的信息,包括:线程名称、序号、优先级prio、JVM线程id(tid,内部id)、系统线程id(nid)、线程状态、锁状态等。

2.语法xt


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1Usage:
2    jstack [-l] <pid>
3        (to connect to running process)
4    jstack -F [-m] [-l] <pid>
5        (to connect to a hung process)
6    jstack [-m] [-l] <executable> <core>
7        (to connect to a core file)
8    jstack [-m] [-l] [server_id@]<remote server IP or hostname>
9        (to connect to a remote debug server)
10
11Options:
12    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
13    -m  to print both java and native frames (mixed mode)
14    -l  long listing. Prints additional information about locks
15    -h or -help to print this help message
16
  • h or help:帮助信息。
  • l:打印关于锁的额外信息。
  • m:同时打印Java和本地语音的栈信息。
  • F:当pid无响应时,强制打印栈信息。

3.常用命令示例


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
1C:\Users\hanchao>jstack 7484
22018-05-08 23:53:03
3Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode):
4
5"DestroyJavaVM" #13 prio=5 os_prio=0 tid=0x00000000047a3800 nid=0x3a8 waiting on condition [0x0000000000000000]
6   java.lang.Thread.State: RUNNABLE
7
8"Thread-1" #12 prio=5 os_prio=0 tid=0x000000001ab7b800 nid=0xe64 waiting on condition [0x000000001bd7f000]
9   java.lang.Thread.State: TIMED_WAITING (sleeping)
10        at java.lang.Thread.sleep(Native Method)
11        at pers.hanchao.concurrent.eg04.ThreadWaitDemo$Restaurant.run(ThreadWaitDemo.java:91)
12        - locked <0x00000000814024f8> (a java.util.LinkedList)
13
14"Thread-0" #11 prio=5 os_prio=0 tid=0x000000001b594800 nid=0x3190 waiting for monitor entry [0x000000001bc7f000]
15   java.lang.Thread.State: BLOCKED (on object monitor)
16        at pers.hanchao.concurrent.eg04.ThreadWaitDemo$Kitchen.run(ThreadWaitDemo.java:53)
17        - waiting to lock <0x00000000814024f8> (a java.util.LinkedList)
18
19"Service Thread" #10 daemon prio=9 os_prio=0 tid=0x000000001a9a3800 nid=0x36e8 runnable [0x0000000000000000]
20   java.lang.Thread.State: RUNNABLE
21
22"C1 CompilerThread2" #9 daemon prio=9 os_prio=2 tid=0x000000001a8fc000 nid=0x2478 waiting on condition [0x0000000000000000]
23   java.lang.Thread.State: RUNNABLE
24
25"C2 CompilerThread1" #8 daemon prio=9 os_prio=2 tid=0x000000001a8a9000 nid=0x3754 waiting on condition [0x0000000000000000]
26   java.lang.Thread.State: RUNNABLE
27
28"C2 CompilerThread0" #7 daemon prio=9 os_prio=2 tid=0x000000001a8a8000 nid=0x3944 waiting on condition [0x0000000000000000]
29   java.lang.Thread.State: RUNNABLE
30
31"Monitor Ctrl-Break" #6 daemon prio=5 os_prio=0 tid=0x000000001a8f2000 nid=0x3460 runnable [0x000000001ae7e000]
32   java.lang.Thread.State: RUNNABLE
33        at java.net.SocketInputStream.socketRead0(Native Method)
34        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
35        at java.net.SocketInputStream.read(SocketInputStream.java:171)
36        at java.net.SocketInputStream.read(SocketInputStream.java:141)
37        at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
38        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
39        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
40        - locked <0x0000000081410958> (a java.io.InputStreamReader)
41        at java.io.InputStreamReader.read(InputStreamReader.java:184)
42        at java.io.BufferedReader.fill(BufferedReader.java:161)
43        at java.io.BufferedReader.readLine(BufferedReader.java:324)
44        - locked <0x0000000081410958> (a java.io.InputStreamReader)
45        at java.io.BufferedReader.readLine(BufferedReader.java:389)
46        at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:64)
47
48"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x000000001946e800 nid=0x1cf8 waiting on condition [0x0000000000000000]
49   java.lang.Thread.State: RUNNABLE
50
51"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x000000001a788800 nid=0x1d20 runnable [0x0000000000000000]
52   java.lang.Thread.State: RUNNABLE
53
54"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x00000000193f9000 nid=0x1774 in Object.wait() [0x000000001a77f000]
55   java.lang.Thread.State: WAITING (on object monitor)
56        at java.lang.Object.wait(Native Method)
57        - waiting on <0x0000000081402c60> (a java.lang.ref.ReferenceQueue$Lock)
58        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
59        - locked <0x0000000081402c60> (a java.lang.ref.ReferenceQueue$Lock)
60        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
61        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
62
63"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x0000000004894000 nid=0x1e08 in Object.wait() [0x000000001a67f000]
64   java.lang.Thread.State: WAITING (on object monitor)
65        at java.lang.Object.wait(Native Method)
66        - waiting on <0x0000000081402e58> (a java.lang.ref.Reference$Lock)
67        at java.lang.Object.wait(Object.java:502)
68        at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
69        - locked <0x0000000081402e58> (a java.lang.ref.Reference$Lock)
70        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
71
72"VM Thread" os_prio=2 tid=0x00000000193d7000 nid=0x3bc4 runnable
73
74"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00000000047b9000 nid=0x3230 runnable
75
76"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00000000047ba800 nid=0xdd0 runnable
77
78"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00000000047bc000 nid=0x336c runnable
79
80"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00000000047bd800 nid=0x3428 runnable
81
82"VM Periodic Task Thread" os_prio=2 tid=0x000000001a9b0000 nid=0x1370 waiting on condition
83
84JNI global references: 18
85

给TA打赏
共{{data.count}}人
人已打赏
安全技术

bootstrap栅格系统自定义列

2021-12-21 16:36:11

安全技术

从零搭建自己的SpringBoot后台框架(二十三)

2022-1-12 12:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索