java – 当JVM在GC中花费时间时,线程转储是什么样的
作者:互联网
在分析Java应用程序时,我注意到有趣的事实.当JVM处于死亡线程转储的GC螺旋时看起来像:
"1304802943@qtp-393978767-9985" prio=10 tid=0x00007f3ed02dd000 nid=0x74e7 in Object.wait() [0x000000004febb000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
- locked <0x00000007aed40048> (a org.mortbay.thread.QueuedThreadPool$PoolThread)
"26774405@qtp-393978767-9984" prio=10 tid=0x00007f3ee4b37000 nid=0x74e6 in Object.wait() [0x0000000045d1a000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
- locked <0x00000007aed83aa0> (a org.mortbay.thread.QueuedThreadPool$PoolThread)
"764808089@qtp-393978767-9983" prio=10 tid=0x00007f3ee4c50000 nid=0x74e5 in Object.wait() [0x000000004ad6a000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
- locked <0x00000007aed5c448> (a org.mortbay.thread.QueuedThreadPool$PoolThread)
因此,TIMED_WAITING状态中有很多线程.从理论上讲,这种情况很容易在正常运行的应用程序中找到(应用程序此刻根本没有任何传入请求),但我甚至找不到单个请求调度线程做一些有用的事情(名义命中率约为100 hps).
这种行为是否与GC有关,或者只是巧合?
解决方法:
回答问题的标题:
What does thread dump look like when JVM spent time in GC?
答案是:你没有办法获得这种转储(以通常的方式).
JVM在达到safepoint之后才处理线程转储请求,这在GC中是不可能发生的.
但是有一种作弊方法可以获得有效的GC的线程转储,并在此文章中提到了未记录的JVMTI函数AsyncGetCallTrace:
http://jeremymanson.blogspot.com/2010/07/why-many-profilers-have-serious.html
它还暗示Oracle Solaris Studio可以be used采取这种混合的本机/ java线程转储.
标签:java,garbage-collection,thread-dump 来源: https://codeday.me/bug/20190626/1293008.html