In Depth Minor GC in Java
In Depth Minor GC in Java
- by utk
It is fast, happens frequently, and is less expensive than Major GC because the Young
Gen is small and short-lived objects are easy to clean.
It consists of:
diff
CopyEdit
+-----------+------------+------------+
| Eden | Survivor 0 | Survivor 1 |
+-----------+------------+------------+
✅ 1. Stop-the-World Pause
• Reachable objects in Eden and the active Survivor space are identified (from GC
roots).
• These live objects are copied into the other Survivor space.
• Objects that survive multiple Minor GCs (e.g., 15 by default) are promoted to Old
Gen.
✅ 3. Eden is Cleared
text
CopyEdit
Eden → Survivor 0 → Survivor 1 → Old Gen
🔹 Advantages of Minor GC
Benefit Why it Matters
Fast Eden is small, copying is quick
Frequent Keeps memory fresh; avoids Old Gen promotion
Mark-and-copy is faster than mark-sweep-
Efficient Algorithm
compact