In-depth understanding of java virtual machine --- virtual machine tool jstat (17)

jstack---not useful
jstack is used to generate a thread snapshot of the current moment of the java virtual machine. A thread snapshot is a collection of method stacks that are being executed by each thread in the current Java virtual machine. The main purpose of generating a thread snapshot is to locate the cause of the thread's long pause, such as inter-thread deadlock, infinite loop, and long time caused by requesting external resources. Time to wait and so on. When the thread is paused, you can view the call stack of each thread through jstack, and you can know what the unresponsive thread is doing in the background, or what resources it is waiting for. If the java program crashes to generate the core file, the jstack tool can be used to obtain the information of the java stack and native stack of the core file, so that you can easily know how the java program crashes and where the problem occurs in the program. In addition, the jstack tool can also be attached to the running java program, and you can see the information of the java stack and the native stack of the running java program at that time. If the currently running java program is in a hung state, 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 : Force output thread stack stack when normal output request is not answered.

-l : Display additional information about locks in addition to the thread stack.

-m : If you call a native method, you can display the stack of c/c++

 

Example

 

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 http://43.154.161.224:23101/article/api/json?id=325318064&siteId=291194637