Java GC Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/Java-GC

Copyright © 2018 by Dr. Herong Yang. All rights reserved.

Java GC Tutorials This book is a collection of tutorial notes and sample codes written by the author while he was learning JVM GC (Garbage Collection) processes. Topics include Java Garbage Collectors, STW (Stop-The-World), Serial Collector, Parallel Collector, Concurrent Collector, G1 Collector, GC Algorithms, Generational GC, Regional GC, Heap Memory Management, Young/New Generation, Tenured/Old Generation, Object Reference, Eden Space, Survivor Spaces, Minor GC, Major GC, Full GC, Performance Tuning, Throughput/Latency Performance, Heap Footprint.

Table of Contents

About This Book

Heap Memory Area and Size Control

Java Exception: "java.lang.OutOfMemoryError: Java heap space"

Memory Allocation Limits on Windows Systems

OutOfMemoryError Comparison of HotSpot and JRockit

JVM Garbage Collection Logging

Garbage Collection Demo Program

Garbage Collection Logging Options

"-XX:+PrintGC" - GC Logging Option for Short Messages

"-XX:+PrintGCDetails" - Option for Detailed GC Messages

"-XX:+PrintGCDateStamps" - Calendar Timestamp on GC Messages

"-XX:+PrintGCApplicationStoppedTime" - Application Pause Durations

"-XX:+PrintGCApplicationConcurrentTime" - Application Running Durations

"-XX:+PrintHeapAtGC" - Print Heap Summary per GC

"-XX:+PrintTenuringDistribution" - Tunuring Distribution

"-XX:+PrintReferenceGC" - Reference Counts per GC

"-XX:+PrintFlagsFinal" - Print JVM Options

Introduction of Garbage Collectors

JVM Memory Manager - Garbage Collector

Generational Garbage Collection in HotSpot

Young Generation Collection - Minor GC

Young Generation Collectors - Serial, PS, ParNew, G1

Tenured Generation Collection - Major GC

Tenured Generation Collectors - Serial, ParOldGen, CMS, G1

Collector Combinations: Serial, Parallel, Concurrent, G1

Serial Collector - "+XX:+UseSerialGC"

What Is Serial Collector

GC Log Message Format for Serial Collector

GC Log Message Examples of Serial Collector

Log Message Types from Serial Collector

Serial Collector Stops Application for Minor/Major GC

Usage Report on Heap Memory Areas

Default NewRatio - Old vs. New Generation

"-XX:NewRatio" - Ratio of Tenured and "new" Generation

"-XX:SurvivorRatio" - Ratio of Eden and Survivor Space

Serial GC Tracing - Tight Heap

Serial GC Tracing - Plenty of Heap

Serial GC Tracing - Aged Live Objects

Serial GC Tracing - Tenuring Threshold

"-XX:TargetSurvivorRatio" - Second Tenuring Condition

Serial GC Tracing - Tenuring Threshold Controlled

"-XX:+NeverTenure" and "-XX:+AlwaysTenure" not Working

Minor GC Triggering Condition of Serial Collector

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

GCPerformance.java - GC Performance Test Program

GCPerformance.java - Program Output

Performance Impact of Wait Time

Performance Impact of Chunk Size

Performance Jumps Not Related to GC

Performance Test and System Interruptions

"START /REALTIME" - Run JVM with Highest Priority

GCPerfP99.java - 99th Percentile Performance

GCPerfP99.java - Output Verification

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

Best Garbage Collector and Configuration

General Suggestions for Better GC Performance

Outdated Tutorials

Outdated: GCTest2.java - Garbage Collection Test Program

Outdated: 640/400/40MB Test on HotSpot Client 1.7

Outdated: 640/400/40MB Test on HotSpot Client 1.6

Outdated: 640/400/40MB Test on JRockit 28.2

Outdated: 441/400/40MB Test on JRockit 28.2

Outdated: 1076/800/80MB Test on HotSpot Client 1.7

Outdated: 1076/800/80MB Test on HotSpot Client 1.6

Outdated: 1076/800/80MB Test on JRockit 28.2

References

Full Version in PDF/EPUB

Keywords: Java, Virtual, Machine, GC, Garbage Collection