Use jstack command

jstack
jstack thread used to generate java virtual machine snapshot of the current time. A snapshot is a method in the current thread java virtual machine each executing thread stack collection, the main purpose of generating a snapshot of the thread is to locate the thread appears long pause, such as inter-thread deadlocks, infinite loop, long requested external resources caused by time to wait so on. When the thread pause to view the call stack of each thread through jstack, you can know that is not responding threads in the end to do something in the background, waiting for something or resources. If java program crashes generate core files, jstack tools can be used java stack and native stack information obtained core files, so you can easily know how java program is a program crashes and where problems occur. In addition, jstack tool also can be attached to the java program is running, see information of java stack and native stack java program running at the time, if the program now run java presentation of state hung, jstack is very useful. Thread [analysis]
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

parameter

-F : When the normal response to the output request is not to force the output stack thread stack.

the -l : In addition to the thread stack, heap, display additional information about the locks.

-m : If you call the local method, you can display c / c ++ stack heap

 

Examples

 

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

Guess you like

Origin www.cnblogs.com/findbetterme/p/11388471.html