gpt4 book ai didi

java - 找出JBoss中哪些线程消耗CPU?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:22:36 27 4
gpt4 key购买 nike

我有一些线程占用大量 CPU,我想找到它们。

我在 linux 机器上。苏斯。在使用 top 并打开线程时,它显示线程消耗高 cpu:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+   PPID COMMAND                                        
28597 acrosspm 20 0 3682m 2.8g 23m R 99 4.4 128:51.01 28481 java
28593 acrosspm 20 0 3682m 2.8g 23m R 97 4.4 129:03.77 28481 java
28598 acrosspm 20 0 3682m 2.8g 23m R 97 4.4 129:12.65 28481 java
28600 acrosspm 20 0 3682m 2.8g 23m R 97 4.4 128:59.34 28481 java
28610 acrosspm 20 0 3682m 2.8g 23m R 97 4.4 129:18.72 28481 java

但是当我使用 jstack -F 28481 时,它与最繁忙的线程 id 不匹配。

我尝试使用 jconsole 和 jvisualvm。他们都无法对线程数据进行采样,因为我认为 jmx 已经坏了(我可以在进程的 CPU 跳到 2000% 之前通过 jmx 连接)

那么有没有其他方法可以找出cpu消耗线程的调用堆栈?

非常感谢。


线程转储的某些部分将是:

Thread 28641 "MSC service thread 1-2": (state = BLOCKED)
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Thread 28640 "MSC service thread 1-1": (state = BLOCKED)
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Thread 28638 "Reference Reaper": (state = BLOCKED)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007825b8268> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
- locked <0x00000007825b8268> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
at org.jboss.modules.ref.References$ReaperThread.run(References.java:68)

VM Thread 28636 "Service Thread": (state = BLOCKED)

VM Thread 28635 "C1 CompilerThread14": (state = BLOCKED)

VM Thread 28634 "C1 CompilerThread13": (state = BLOCKED)

VM Thread 28633 "C1 CompilerThread12": (state = BLOCKED)

VM Thread 28632 "C1 CompilerThread11": (state = BLOCKED)

VM Thread 28631 "C1 CompilerThread10": (state = BLOCKED)

VM Thread 28630 "C2 CompilerThread9": (state = BLOCKED)

VM Thread 28629 "C2 CompilerThread8": (state = BLOCKED)

VM Thread 28628 "C2 CompilerThread7": (state = BLOCKED)

VM Thread 28627 "C2 CompilerThread6": (state = BLOCKED)

VM Thread 28626 "C2 CompilerThread5": (state = BLOCKED)

VM Thread 28625 "C2 CompilerThread4": (state = BLOCKED)

VM Thread 28624 "C2 CompilerThread3": (state = BLOCKED)

VM Thread 28623 "C2 CompilerThread2": (state = BLOCKED)

VM Thread 28622 "C2 CompilerThread1": (state = BLOCKED)

VM Thread 28621 "C2 CompilerThread0": (state = BLOCKED)

VM Thread 28620 "JDWP Event Helper Thread": (state = BLOCKED)

VM Thread 28619 "JDWP Transport Listener: dt_socket": (state = BLOCKED)

Thread 28618 "Signal Dispatcher": (state = BLOCKED)

Thread 28617 "Finalizer": (state = BLOCKED)
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
- locked <0x0000000782459cf0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189)

Thread 28616 "Reference Handler": (state = BLOCKED)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:125)
- waiting to lock <0x0000000781816e20> (a java.lang.ref.Reference$Lock)

最佳答案

事实证明,所有这些线程都是垃圾收集线程。

我们的程序生成非常非常大的对象并保存在内存中。

当堆运行不足时,gc 线程将完成它们的工作。由于所有这些对象都在旧区域中,并且没有一个可以被释放,线程继续运行 FGC。

这就是cpu这么高的原因。

关于java - 找出JBoss中哪些线程消耗CPU?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19020026/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com