What does thread dump looks like when JVM spent time in GC

拟墨画扇 提交于 2019-12-01 19:28:12

Answering just the question's title:

What does thread dump look like when JVM spent time in GC?

The answer is: you have no means to obtain such dump (in a usual way).

JVM processes the request for thread dump only after reaching safepoint which just can't happen while in GC.

But there is a cheat way to obtain active GC's thread dump with help of undocumented JVMTI function AsyncGetCallTrace which is mentioned in this post:

http://jeremymanson.blogspot.com/2010/07/why-many-profilers-have-serious.html

It also hints that Oracle Solaris Studio can be used to take such mixed native/java thread dumps.

Try a jmap -histo:live over time, you can compare output, see which object types are growing.

You need to have the JDK installed for jmap. http://docs.oracle.com/javase/6/docs/technotes/tools/share/jmap.html

A warning, jmap is intensive, it will pause all threads while it's running, which should only be a few seconds. Processes can core dump because it's intensive, generally it's quick and safe, but I have see it lock up or kill large applications, multi-gig heaps.

My guess is you have a thread pool which is waiting for something to do. If your process is efficient and you have even 100 requests per second you may have trouble catching even one thread doing something. I suggest you look at the CPU load of your process. If its 50%, you have a 50% chance of finding one thread (possibly not a request thread) doing something.

If you want to see what your server spends its time doing, I would try a profiler like VisualVM, or a commercial profiler like YourKit.

Doing a google search for you code, I found a different version http://grepcode.com/file/repo1.maven.org/maven2/org.mortbay.jetty/jetty-util/7.0.0.pre5/org/mortbay/thread/QueuedThreadPool.java however I suspect your threads are TIMED_WAIT in this block int he run() method

                // We are idle
                // wait for a dispatched job
                synchronized (this)
                {
                    if (_job==null)
                        this.wait(getMaxIdleTimeMs());
                    job=_job;
                    _job=null;
                }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!