并行垃圾收集器是否在主程序旁边的单独线程上运行

时间:2018-12-15 14:47:57

标签: java performance garbage-collection visualvm

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

顺便说一句,我正在使用Visual VM,也可以从那里观察吗?例如,在->“线程”标签部分中,因为找不到它。

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)

1 个答案:

答案 0 :(得分:1)

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

...

"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