Java GC Tutorials - Herong's Tutorial Examples
∟Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
This chapter provides tutorial notes and example codes on the Concurrent Mark-Sweep Collector specified by the '+XX:+UseConcMarkSweepGC' JVM option. Topics include introduction to Concurrent Mark-Sweep (CMS) Collector; CMS Collector log message format; demonstration of reduction of stop-the-world by running parts of Mark and Sweep step concurrently with the application.
What Is Concurrent Mark-Sweep (CMS) Collector
Concurrent Mark-Sweep Collector GC Log Message Format
Reduce Stop-The-World with Concurrent Mark and Sweep
Parallel New (ParNew) Collector for Minor GC
ParNew Collector - Tenuring Age Distribution
Maximum Logging of All Phases on Young GC
"-XX:ParallelGCThreads=6" - Young GC Parallel Threads
"-XX:MaxTenuringThreshold=0" - Tenuring Objects Immediately
"-XX:CMSInitiatingOccupancyFraction=20" - Initiate CMS
Maximum Logging of All Phases on Old GC
Maximum Logging of All Phases on Full GC
"-XX:ParallelGCThreads=6" - Old GC Parallel Threads
"-XX:ConcGCThreads=3" - Old GC Concurrent Threads
Takeaways:
- The Concurrent Mark-Sweep (CMS) Collector, -XX:+UseConcMarkSweepGC, was
deprecated in HotSpot JVM version 9.0 and will likely be removed in a future release.
- The CMS collector actually
uses the Parallel New (ParNew) Collector of the Young generation
and the Concurrent Mark Sweep (CMS) Collector of the Tenured generation.
- The CMS Collector uses "ParNew" to represent Young Generation GC
in log messages.
- The CMS Collector uses "Old" to represent Tenured Generation GC
in log messages.
- The CMS Collector performs Old (Major) GC with multiple threads concurrently
without stopping the application most of the time.
- Application is stopped by the CMS Collector for Initial Mark and Final Mark steps of Major GC.
- Application is stopped by the CMS Collector for Minor GC.
- Application is stopped by the CMS Collector for Full GC.
- The CMS collector is also called Low-Latency Collector,
because it reduces the application pause time. But it may slowdown the application,
because the GC is running concurrently with the application.
It's a good choice for interactive applications like Websites.
- ParNew collector is used to perform Young generation GC
when "-XX:+UseConcMarkSweepGC" option is used.
- ParNew maintains a Tenuring Age Distribution list to determine
object promotion to Tenured generation.
- Tenured generation occupancy percentage initiates the CMS GC.
- CMS Concurrent mode may fail, if Tenured generation gets fully
occupied before it can finish the GC process.
- The CMS collector does uses multiple threads for some phases in the GC process.
- The number of threads in CMS parallel (stop-the-world) phases can be controlled by the "-XX:ParallelGCThreads=n" option.
- The number of threads in 1 CMS concurrent phase, Mark phase, can be controlled by the "-XX:ConcGCThreads=n" option.
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"
►Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
Garbage First (G1) Collector - "+XX:+UseG1GC"
The Z Garbage Collector (ZGC) - "+XX:+UseZGC"
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
References
Full Version in PDF/EPUB