Java thread high CPU usage analysis method

Source: Internet
Author: User
Tags cpu usage high cpu usage

Methods and steps to analyze the high CPU usage of Java threads:

1) To view the CPU occupancy rate TOP10 PID

[Root@qipsuit1 ~]# Ps-aux | Sort-k3nr | head-10
Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.8/faq
root     30428  1.3 12513592 430904 pts/7 Sl   14:20 135:35 java -djava.ext.dirs=/qip/run/app/qip-collector/-jar

2 Display the list of threads and sort by CPU-intensive threads

[Root@qipsuit1 ~]# ps-mp 30428-o thread,tid,time | Sort-rn
user     %cpu PRI SCNT wchan  user SYSTEM   TID     time
root     99.9         -      -30932 01:08:18
Root 99.8---      30933 01:08:18

3 converts the required thread ID to a 16-in format

[Root@qipsuit2 ~]# printf "%x\n" 30932
78d4
[root@qipsuit1 ~]# printf "%x\n" 30933
78d5

4) View Stack

[root@qipsuit1 ~]# jstack 30428 |grep 78d4-a "Thread-15" prio=10 tid=0x00007fa28c058800 nid= 0x78d4 runnable [0x00007fa3a8e49000] Java.lang.Thread.State:RUNNABLE at COM.GTSTAR.COLLECTOR.THREAD.MSGSAVETHR Ead.run (msgsavethread.java:68) at Java.lang.Thread.run (thread.java:745) "Thread-13" prio=10 tid=0x00007fa28c05680 0 nid=0x78d3 waiting on condition [0x00007fa3a8f4a000] Java.lang.Thread.State:TIMED_WAITING (sleeping) at Java . lang.
        Thread.Sleep (Native method) at Com.gtstar.collector.thread.MemoryMsgSaveThread.run (memorymsgsavethread.java:33) At Java.lang.Thread.run (thread.java:745) 
[Root@qipsuit1 ~]# jstack 30428 |grep 78d5-a
' Thread-17 ' prio=10 tid=0x00007fa28c05b000 nid=0x78d5 runnable [0x000 07FA3A8D48000]
   Java.lang.Thread.State:RUNNABLE at
        Com.gtstar.collector.thread.AckMsgSaveThread.run ( ackmsgsavethread.java:66) at
        Java.lang.Thread.run (thread.java:745)

"Thread-15" prio=10 tid= 0x00007fa28c058800 nid=0x78d4 runnable [0x00007fa3a8e49000]
   Java.lang.Thread.State:RUNNABLE
        at Com.gtstar.collector.thread.MsgSaveThread.run (msgsavethread.java:68) at
        Java.lang.Thread.run (Thread.java : 745)

Watch the red part.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.