Understanding Java JVM Garbage Collectors: From Serial to Shenandoah

This article explains the main Java JVM garbage collectors—including Serial, Parallel, CMS, G1, ZGC, Epsilon, and Shenandoah—detailing their architectures, pause characteristics, suitable workloads, and key advantages, helping developers choose the right collector for different application sizes and latency requirements.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Understanding Java JVM Garbage Collectors: From Serial to Shenandoah

Serial Collector

Serial garbage collector is the most basic collector, using a single thread for garbage collection. It pauses all application threads until collection finishes, is simple, low‑resource, and suitable for small applications such as mobile or desktop programs.

Parallel Collector

Parallel garbage collector uses multiple threads to accelerate the collection process, improving application performance. It can run concurrently on multiple CPUs, increasing efficiency, and is suitable for medium‑sized applications that require high throughput, such as web services and large‑scale enterprise systems.

CMS Collector

CMS (Concurrent Mark‑Sweep) is a low‑pause collector that uses a mark‑and‑sweep algorithm, primarily for the old generation. It works in two phases: a concurrent marking phase where multiple threads identify live objects without stopping the application, and a sweeping phase that reclaims memory.

G1 Collector

G1 collector adopts a generational approach, dividing the heap into many equal‑sized regions (Regions). Each region is classified as Eden, Survivor, or Old, and large objects are placed in Humongous regions. G1 aims to reduce pause times while avoiding memory fragmentation, making it suitable for large applications that need predictable latency, such as financial transaction systems.

ZGC Collector

ZGC (Z Garbage Collector), introduced in JDK 11, targets ultra‑low latency. It uses a concurrent marking‑copy algorithm with read barriers, allowing fast heap scanning with virtually no pause. ZGC reduces pause times while maintaining throughput, fitting memory‑intensive or large‑scale data processing applications.

Epsilon Collector

Epsilon is an experimental collector designed to eliminate GC pause time entirely. It provides no actual garbage collection, which can boost performance and predictability for workloads that can tolerate unbounded memory growth, such as high‑performance computing or scientific simulations.

-XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC

Shenandoah Collector

Shenandoah, introduced in JDK 12, focuses on large‑heap and low‑latency scenarios. It achieves very short pause times by performing most GC work concurrently with the running application, making it suitable for applications that require both large memory footprints and minimal latency.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaJVMperformanceGarbage Collection
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.