JVM調優命令-jstack

jstack
jstack用於生成java虛擬機當前時刻的線程快照。線程快照是當前java虛擬機內每一條線程正在執行的方法堆棧的集合,生成線程快照的主要目的是定位線程出現長時間停頓的緣由,如線程間死鎖、死循環、請求外部資源致使的長時間等待等。 線程出現停頓的時候經過jstack來查看各個線程的調用堆棧,就能夠知道沒有響應的線程到底在後臺作什麼事情,或者等待什麼資源。 若是java程序崩潰生成core文件,jstack工具能夠用來得到core文件的java stack和native stack的信息,從而能夠輕鬆地知道java程序是如何崩潰和在程序何處發生問題。另外,jstack工具還能夠附屬到正在運行的java程序中,看到當時運行的java程序的java stack和native stack的信息, 若是如今運行的java程序呈現hung的狀態,jstack是很是有用的。【線程分析】
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@localhost bin] # jstack -help
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

參數java

-F:當正常輸出請求不被響應時,強制輸出線程棧堆。c++

-l:除線程棧堆外,顯示關於鎖的附加信息。apache

-m:若是調用本地方法的話,能夠顯示c/c++的棧堆bash


示例socket

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
[root@localhost bin] # jstack -m 24971 | more
Attaching to process ID 24971, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.79-b02
Deadlock Detection:
 
No deadlocks found.
 
----------------- 24972 -----------------
0x00007fe07d2cd69d  __GI___poll + 0x2d
0x00007fe070dc80a7  Java_java_net_PlainSocketImpl_socketAccept + 0x1e7
0x00007fe0745a3d98  * java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) bci:0 (Interpreted frame)
0x00007fe074597058  * java.net.AbstractPlainSocketImpl.accept(java.net.SocketImpl) bci:7 line:398 (Interpreted frame)
0x00007fe074597058  * java.net.ServerSocket.implAccept(java.net.Socket) bci:60 line:530 (Interpreted frame)
0x00007fe074597058  * java.net.ServerSocket.accept() bci:48 line:498 (Interpreted frame)
0x00007fe074597233  * org.apache.catalina.core.StandardServer.await() bci:180 line:470 (Interpreted frame)
0x00007fe074597706  * org.apache.catalina.startup.Catalina.await() bci:4 line:782 (Interpreted frame)
0x00007fe074597058  * org.apache.catalina.startup.Catalina.start() bci:209 line:728 (Interpreted frame)
0x00007fe0745914e7  <StubRoutines>
0x00007fe07c967e95  _ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread + 0x365
0x00007fe07c9668f8  _ZN9JavaCalls4callEP9JavaValue12methodHandleP17JavaCallArgumentsP6Thread + 0x28
0x00007fe07cbfdeef  _ZN10Reflection6invokeE19instanceKlassHandle12methodHandle6Handleb14objArrayHandle9BasicTypeS3_bP6Thread + 0x
47f
0x00007fe07cbfeca0  _ZN10Reflection13invoke_methodEP7oopDesc6Handle14objArrayHandleP6Thread + 0x160
相關文章
相關標籤/搜索