"-XX:+PrintGCTaskTimeStamps" - Print GC Threads

This section describes how to use the '-XX:+PrintGCTaskTimeStamps' JVM option to show multiple GC threads used by the Parallel Collector.

One key characteristics of the Parallel collector is that it uses multiple parallel threads to perform garbage collection processes.

Let's use the "-XX:+PrintGCTaskTimeStamps" JVM option to confirm this behavior:

herong> \progra~1\java\jdk1.8.0\bin\java -Xms2m -Xmx64m -XX:+UseParallelGC \
   -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \
   -XX:+PrintGCTaskTimeStamps GarbageCollection > output.txt
(Ctrl-C)

herong> more output.txt
Step/TotalMemory/FreeMemory/UsedMemory:
0.111: [GC (Allocation Failure) [PSYoungGen: 512K->248K(768K)]
   1280K->1184K(1792K), 0.0009278 secs]

VM-Thread 259872 261890 262332
GC-Thread 0 entries: 6
  [ noop task 260045 260047 ]
  [ old-to-young-roots-task 260049 260070 ]
  [ old-to-young-roots-task 260071 260088 ]
  [ thread-roots-task 260089 260129 ]
  [ thread-roots-task 260129 260506 ]
  [ steal-task 260506 261816 ]
GC-Thread 1 entries: 8
  [ thread-roots-task 260147 260149 ]
  [ scavenge-roots-task 260150 260152 ]
  [ scavenge-roots-task 260153 260154 ]
  [ scavenge-roots-task 260154 260157 ]
  [ scavenge-roots-task 260157 260204 ]
  [ scavenge-roots-task 260204 261783 ]
  [ steal-task 261784 261815 ]
  [ waitfor-barrier-task 261815 261882 ]
GC-Thread 2 entries: 8
  [ old-to-young-roots-task 260066 260068 ]
  [ old-to-young-roots-task 260070 260071 ]
  [ scavenge-roots-task 260072 260114 ]
  [ thread-roots-task 260115 260117 ]
  [ thread-roots-task 260118 260455 ]
  [ scavenge-roots-task 260456 260457 ]
  [ scavenge-roots-task 260457 260458 ]
  [ steal-task 260458 261816 ]
GC-Thread 3 entries: 5
  [ scavenge-roots-task 260088 260110 ]
  [ thread-roots-task 260112 260116 ]
  [ thread-roots-task 260117 260119 ]
  [ thread-roots-task 260119 260671 ]
  [ steal-task 260672 261825 ]
0.112: [Full GC (Ergonomics) [PSYoungGen: 248K->247K(768K)]
   [ParOldGen: 936K->922K(2304K)] 1184K->1169K(3072K),
   [Metaspace: 1555K->1555K(4480K)], 0.0031605 secs]

VM-Thread 263022 266499 270491
GC-Thread 0 entries: 6
  [ noop task 262990 262991 ]
  [ mark-from-roots-task 263041 263135 ]
  [ thread-roots-marking-task 263136 263147 ]
  [ thread-roots-marking-task 263148 263513 ]
  [ steal-marking-task 263514 264091 ]
  [ steal-region-task 266591 269346 ]
GC-Thread 1 entries: 10
  [ noop task 262974 262975 ]
  [ mark-from-roots-task 263068 263112 ]
  [ thread-roots-marking-task 263112 263117 ]
  [ thread-roots-marking-task 263117 263119 ]
  [ thread-roots-marking-task 263119 263120 ]
  [ thread-roots-marking-task 263120 263804 ]
  [ steal-marking-task 263805 264084 ]
  [ update-dense_prefix-task 266560 266565 ]
  [ steal-region-task 266567 269063 ]
  [ waitfor-barrier-task 269063 269825 ]
GC-Thread 2 entries: 14
  [ noop task 263019 263019 ]
  [ thread-roots-marking-task 263084 263250 ]
  [ mark-from-roots-task 263251 263252 ]
  [ mark-from-roots-task 263252 263253 ]
  [ mark-from-roots-task 263253 263254 ]
  [ steal-marking-task 263254 264008 ]
  [ waitfor-barrier-task 264009 264109 ]
  [ drain-region-task 266536 266537 ]
  [ drain-region-task 266538 266538 ]
  [ drain-region-task 266538 266538 ]
  [ drain-region-task 266539 266539 ]
  [ update-dense_prefix-task 266539 266557 ]
  [ update-dense_prefix-task 266557 266560 ]
  [ steal-region-task 266560 269347 ]
GC-Thread 3 entries: 8
  [ noop task 263005 263005 ]
  [ thread-roots-marking-task 263233 263236 ]
  [ mark-from-roots-task 263236 263239 ]
  [ mark-from-roots-task 263239 263240 ]
  [ mark-from-roots-task 263241 263242 ]
  [ mark-from-roots-task 263243 263266 ]
  [ steal-marking-task 263267 264086 ]
  [ steal-region-task 266580 269666 ]
...

From the output, I can see that the Parallel Collector did use 4 multiple threads to perform the first Minor GC. But I am not sure if those multiple threads were executed parallely on multiple CPUs.

The output also shows that the Parallel Collector did use 4 multiple threads to perform the first Major GC too.

Table of Contents

 About This Book

 Heap Memory Area and Size Control

 JVM Garbage Collection Logging

 Introduction of Garbage Collectors

 Serial Collector - "+XX:+UseSerialGC"

Parallel Collector - "+XX:+UseParallelGC"

 What Is Parallel Collector

 Parallel Collector GC Log Message Format

"-XX:+PrintGCTaskTimeStamps" - Print GC Threads

 "-XX:ParallelGCThreads=n" - # of Threads

 Parallel Collector Stops Application for Minor/Major GC

 PSYoungGen Collector Using Tenuring Age

 Parallel Collector Changing NewRatio and SurvivorRatio

 Parallel Collector Adaptive Size Policy

 Adaptive Size Policy Log Messages

 "-XX:+PrintAdaptiveSizePolicy" - Minor GC Report

 Adaptive Size Policy Changed Survivor Space

 Adaptive Size Policy Changed Eden Space

 Adaptive Size Policy for Best Latency

 Adaptive Size Policy for Best Throughput

 Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"

 Garbage First (G1) Collector - "+XX:+UseG1GC"

 Object References and Garbage Collection

 Garbage Collection Performance Test Program

 Performance Tests on Serial Collector

 Performance Tests on Parallel collector

 Performance Tests on Concurrent collector

 Performance Tests on G1 collector

 Garbage Collection Performance Test Summary

 Archived Tutorials

 References

 Full Version in PDF/EPUB