Garbage First (G1) Collector - "+XX:+UseG1GC"
This chapter provides tutorial notes and example codes on the Garbage First (G1) Collector specified by the '+XX:+UseG1GC' JVM option. Topics include introduction the G1 Collector; G1 log message format; Stop-The-World behavior of G1 Collector.
These sections are omitted from this Web preview version. To view the full content,
see information on how to obtain the full version this book.
What Is Garbage First (G1) Collector
Garbage First GC Log Message Format
"-XX:ParallelGCThreads=6" - G1 Parallel Threads
Stop-The-World Log Messages of Garbage First Collector
"-XX:+PrintHeapAtGC" - Heap at Each GC
"-XX:G1HeapRegionSize=n" - G1 Region Size
G1 Humongous Allocation - Objects Too Large
"-XX:+PrintTenuringDistribution" - Object Age
"-XX:+MaxTenuringThreshold=0" - Skip G1 Survivors
G1 Major GC Phases
G1 Major GC Copy Phase Failed - Full GC
G1 Major GC Mark Phase Failed - Full GC
- The Garbage First (G1) Collector, -XX:+UseG1GC, improves the performance of
the Concurrent Mark-Sweep (CMS) Collector by dividing the Heap area into regions
and working on regions mostly filled with garbage first.
- Application is stopped by the G1 Collector for Minor GC,
which runs in multiple parallel threads.
- G1 Major GC has 7 phases:
initial mark, root region scan, mark, final mark, cleanup, concurrent cleanup, copy.
- G1 Major GC initial mark phase is piggybacked with a Minor GC.
- G1 Major GC root region scan and mark phases run concurrently without
stopping the application.
- G1 Major GC final mark and cleanup phases run serially with application stopped.
- G1 Major GC concurrent cleanup phase runs concurrently without
stopping the application.
- G1 Major GC initial copy phase is piggybacked with one or more Minor GCs.
- "-XX:G1HeapRegionSize=n" can be used to specify the size of regions used by the
G1 collector. The default region size is 1024K.
- Any object that is more than half a region size is considered a "Humongous object".
Such an object is allocated directly in the old generation into "Humongous regions".
A Humongous region is a contiguous set of regions.
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"
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
Full Version in PDF/EPUB