并行垃圾收集器是否与主程序一起在单独的线程上运行

Does the parallel garbage collector runs on a separate thread alongside the main program

我正在使用 JKD8,正如我在默认情况下使用以下命令看到的那样,JVM 使用并行垃圾收集器。我如何观察垃圾是否与主程序一起在单独的线程上运行?有没有类似-XX:-PrintGCDetails选项的参数?

顺便问一下,我正在使用 Visual VM,我也可以从那里观察它吗?例如在 ->"Threads" 选项卡部分,因为我找不到它。

java -XX:+PrintCommandLineFlags  -XX:-PrintGCDetails -version
-XX:InitialHeapSize=535233856 -XX:MaxHeapSize=8563741696 -XX:+PrintCommandLineFlags -XX:-PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

垃圾收集器 运行 在单独的线程中。您可以在线程转储中观察到这一点:

...

"VM Thread" os_prio=0 tid=0x00007f4fec078000 nid=0x74c9 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f4fec01f800 nid=0x74c5 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f4fec021800 nid=0x74c6 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f4fec023000 nid=0x74c7 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f4fec025000 nid=0x74c8 runnable 

...

您可以通过向进程发送 SIGQUIT (3) 来生成线程转储:

kill -SIGQUIT <pid>

请参阅 RedHat:https://access.redhat.com/solutions/18178