Let's see how to do it!Īs a rule of thumb, for abnormally high CPU usage we only need to look at RUNNABLE threads. On the other hand, we'll need to keep and group the important information from the tons of logs produced by the stack trace. Thread dumps are fairly similar in their structure, but we'll want to get rid of the non-important data generated for our use case. We should pay special attention to this when memory leak occurs because they aren't automatically garbage collected: JNI global refs: 15, weak refs: 0 "VM Periodic Task Thread" os_prio=31 cpu=5.82ms elapsed=11.42s tid=0x00007fd7a5c35fd0 nid=0x9903 waiting on conditionįinally, the dump displays the Java Native Interface (JNI) references. Therefore, we are able to identify the root of the problem by looking at the source code or other internal JVM processing.Īt the end of the dump, we'll notice there are several additional threads performing background operations such as Garbage Collection (GC) or object termination: "VM Thread" os_prio=31 cpu=1.85ms elapsed=11.50s tid=0x00007fd7a7a0c170 nid=0x3603 runnable If we look further down we'll see all the JVM methods executed by our application behind the scenes. (a .ReentrantLock$NonfairSync)Īt a first glance, we see that the main stack trace is executing java.io.BufferedReader.readLine which is the expected behavior. Let's focus only on the interesting bits of the stack waiting to consume the message: "Monitor Ctrl-Break" #12 daemon prio=5 os_prio=31 cpu=17.42ms elapsed=11.42s tid=0x00007fd7a6896200 nid=0圆603 runnable Īt .SocketDispatcher.read0( /Native Method)Īt .SocketDispatcher.read( /SocketDispatcher.java:47)Īt .yRead( /NioSocketImpl.java:261)Īt .NioSocketImpl.implRead( /NioSocketImpl.java:312)Īt .NioSocketImpl.read( /NioSocketImpl.java:350)Īt .NioSocketImpl$1.read( /NioSocketImpl.java:803)Īt $SocketInputStream.read( /Socket.java:981)Īt .StreamDecoder.readBytes( /StreamDecoder.java:297)Īt .StreamDecoder.implRead( /StreamDecoder.java:339)Īt .StreamDecoder.read( /StreamDecoder.java:188)Īt java.io.InputStreamReader.read( /InputStreamReader.java:181)Īt java.io.BufferedReader.fill( /BufferedReader.java:161)Īt java.io.BufferedReader.readLine( /BufferedReader.java:326)Īt java.io.BufferedReader.readLine( /BufferedReader.java:392)Īt .2$1.run(AppMainV2.java:61) We can see from top to bottom what the different threads are doing at the time of the snapshot. Stack trace: the most important source of information to decipher what is happening with our application.Native ID (nid): the unique ID given by the OS, useful to extract correlation with CPU or memory processing.Java ID (tid): the unique ID given by the JVM.Priority (prior): the priority of the thread.Name: it can provide useful information if developers include a meaningful thread name.
0 Comments
Leave a Reply. |