JAVA線程CPU佔用率過高分析方法

來源:互聯網
上載者:User

分析java線程CPU佔用率過高的方法和步驟:

1) 查看CPU佔用率TOP10 的PID

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

2) 顯示線程列表,並按照CPU佔用高的線程排序

[root@qipsuit1 ~]# ps -mp 30428 -o THREAD,tid,time | sort -rnUSER     %CPU PRI SCNT WCHAN  USER SYSTEM   TID     TIMEroot     99.9  19    - -         -      - 30932 01:08:18root     99.8  19    - -         -      - 30933 01:08:18

3) 將需要的線程ID轉換為16進位格式

[root@qipsuit2 ~]# printf "%x\n" 3093278d4[root@qipsuit1 ~]# printf "%x\n" 3093378d5

4) 查看stack

[root@qipsuit1 ~]# jstack 30428 |grep 78d4 -A 30"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)"Thread-13" prio=10 tid=0x00007fa28c056800 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 30"Thread-17" prio=10 tid=0x00007fa28c05b000 nid=0x78d5 runnable [0x00007fa3a8d48000]   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)

注意看紅色部分

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.