zoukankan      html  css  js  c++  java
  • 一次java Cpu占用过高的排查

    某一个项目CPU占用率一直很高,经常在40%-50%之间,最近比较闲,就开始了排查工作。

    1.通过 jstack命令输出进程的堆栈信息

    jstack 2788 >C:log.txt

    将堆栈信息输出到log.txt

    "dubbo-remoting-client-heartbeat-thread-1" #46 daemon prio=5 os_prio=0 tid=0x000000005c53e000 nid=0x240c waiting on condition [0x000000006447f000]
       java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000e17fc110> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    
       Locked ownable synchronizers:
        - None
    
    "Hashed wheel timer #1" #41 prio=5 os_prio=0 tid=0x000000005c53c800 nid=0x271c runnable [0x0000000063fae000]
       java.lang.Thread.State: RUNNABLE
        at java.lang.Thread.sleep(Native Method)
        at org.jboss.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:504)
        at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:402)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at java.lang.Thread.run(Thread.java:745)
    
       Locked ownable synchronizers:
        - None
    
    "DubboClientReconnectTimer-thread-1" #44 daemon prio=5 os_prio=0 tid=0x0000000059883800 nid=0x2700 waiting on condition [0x000000006362f000]
       java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000e1825be0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

    2. 通过ProcessExplorer查找CPU占用过高的线程

    从图中可以看到,占用CPU过高的线程ID是8924,再将8924转换为16进行,在刚刚输出的log.txt中查询对应的堆栈信息。

    之后再查询相应的代码。CPU过高一般都是有死循环了。

  • 相关阅读:
    动态规划 最长公共子序列 LCS,最长单独递增子序列,最长公共子串
    梳排序(Comb sort)
    地精排序(Gnome Sort) 算法
    vs2010 调试 调用堆栈 窗口
    vs2010 条件断点 has changed是什么意思?
    vs2010根据字符串内容添加断点
    vs2010 调试中监视变量
    vs2010断点使用技巧
    区间重合判断(pojg校门外的树)
    转:Linus:利用二级指针删除单向链表
  • 原文地址:https://www.cnblogs.com/Gyoung/p/6273074.html
Copyright © 2011-2022 走看看