Note that there are some explanatory texts on larger screens.

plurals
  1. POWith recent Sun JVMs (1.6), is it possible to get GC thread information?
    text
    copied!<p>With JRockit, you can get the full list of threads by any means, and all of these means include information about the Garbage Collection Thread(s):</p> <p>1) Asking the <code>Thread</code> class for the information:</p> <pre><code>Thread.getAllStackTraces(); </code></pre> <p>2) Using <code>ThreadGroup</code> to get that information:</p> <pre><code>ThreadGroup root = Thread.currentThread().getThreadGroup(); while (root.getParent() != null) { root = root.getParent(); } Thread[] list = new Thread[root.activeCount() + 5]; root.enumerate(list, true); </code></pre> <p>3) Using JMX to get the list:</p> <pre><code>ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean(); long[] tids = THREAD_MX_BEAN.getAllThreadIds(); ThreadInfo[] tinfos = THREAD_MX_BEAN.getThreadInfo(tids); </code></pre> <p>4) CTRL-BREAK</p> <p>However, using the Sun JVM -- at least recent Java 6 releases -- only CTRL-BREAK seems to include the Garbage Collection threads and the VM Periodic Task thread. I find it useful to monitor CPU used by the GC threads so my application can detect and log when GC is using most of the CPU time. Without this information, you only know when GC exceeds certain set thresholds.</p> <p>If I can even just find out the Thread ID of the GC threads, then JMX will probably give the rest of the information I need (unless there is something different about these Threads). For example, using the method:</p> <pre><code>long threadId = tids[0]; long cpuTime = THREAD_MX_BEAN.getThreadCpuTime(threadId); </code></pre> <p>Does anyone know how -- or if it is known to be not possible -- to get information about the garbage collection Thread(s) using the Sun JVM?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload