Java Garbage Collection

2026-11-18 ยท garbage collection

notes / DOCS

Required reading: Java Garbage Collectors

In Java

  1. serial gc
  2. parallel gc
  3. concurrent mark sweep
  4. garbage first (G1)
  5. zgc
  6. shehnandoah gc
  7. epsilon gc
  8. azul c4 gc
  9. ibm metronome gc
  10. sap garbage collector

1. Serial Garbage Collectors

initial mark: all objects directly referenced
     |
     v
(serial) marking: traverse reachable objects
     |
     v
remark: resume briefly and continue marking
     |
     v
sweep and compact: sweep memory to dealloc 0 refs, compact to contiguous
     |
     v
free: update free memory 

Costs:

Pros:

2. Parallel GC

Costs:

Pros:

3. CMS

handle object modifications during the concurrent marking

Costs:

Pros:

4. G1 (Garbage-First) GC

Costs:

Pros:

5. ZGC

designed for large heaps

Costs:

Pros:

6. Shehnandoah GC

large heaps and low latency, concurrent evacuation

"G1 on steriods"

Pros:

7. Epsilon GC

special purpose when GC not required (no-op gc) basically a fake gc

not even that its basically no gc at all why tf does it have a name

8. Azul C4 GC

~explosive~

Continuously Concurrent Compacting Collector

fucking proprietary

9. IBM metronome gc

metronome trauma

real time systems with strict determinism, low pause times

10. SAP GC

also proprietary welp

moew