Senior
What is the default garbage collector used? What others do you know?
sobes.tech AI
Answer from AI
By default, modern versions of the JVM (starting from Java 9) use the G1 (Garbage-First) garbage collector. It is optimized for multi-processor systems and large heaps, aiming to minimize pause times during garbage collection.
Other well-known garbage collectors in the JVM include:
- Serial GC — single-threaded, simple, suitable for small applications.
- Parallel GC (Throughput Collector) — multi-threaded, focused on maximum throughput.
- CMS (Concurrent Mark Sweep) — aims to minimize pauses, works in parallel with the application.
- ZGC — a low-latency, scalable garbage collector for large heaps.
- Shenandoah — similar to ZGC, with low pauses.
The choice of garbage collector depends on requirements for latency, throughput, and heap size.