Skip to main content

Explain garbage collection algorithms in Java.

Mid Java
Quick Answer Java GC algorithms: Serial (single-threaded, for small heaps), Parallel/Throughput (multi-threaded GC, good for batch processing), CMS (Concurrent Mark Sweep - deprecated, low pause), G1 (default since Java 9 - region-based, balances throughput and latency), ZGC (Java 11+ - sub-millisecond pauses for huge heaps), Shenandoah (similar to ZGC). Choose based on your latency vs throughput requirements.

Answer

Mark-and-Sweep marks live objects and removes unused ones.
Generational GC optimizes by separating objects into young and old generations.
Stop-the-world pauses occur during GC phases.
Modern collectors like G1 and ZGC reduce latency.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice