Explain JVM Memory Architecture and the Evolution of Java Garbage Collectors (G1, ZGC, Parallel).
Quick Revision Summary
JVM separates heap into Young and Old generations based on weak generational hypothesis. G1 balances throughput with bounded pause times, while ZGC achieves sub-millisecond latency.
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
The JVM Memory Structure is divided into:
- Heap Memory: Shared among all threads, storing object instances. Divided into Young Generation (Eden space, Survivor spaces S0/S1) and Old Generation (Tenured).
- Metaspace (Native Memory): Stores class metadata, bytecode, and method signatures (replaced PermGen in Java 8).
- JVM Stacks: Thread-private, stores stack frames (local variables, operand stack).
Garbage Collector Evolution:
- Parallel GC: Multi-threaded collector focused on maximum application throughput; incurs Stop-The-World (STW) pauses.
- G1 GC (Garbage-First): Default since Java 9. Divides heap into thousands of equal-sized regions. Prioritizes collecting regions with the most garbage to meet a target maximum pause time (
-XX:MaxGCPauseMillis). - ZGC (Z Garbage Collector): Low-latency concurrent GC designed for multi-terabyte heaps with pause times consistently below 1 millisecond.
Interviewer Evaluation Points & Scoring Rubric
- 1 1. Outlines Heap vs Metaspace vs Stack. 2. Explains Young/Old generation rationale. 3. Compares Parallel, G1, and ultra-low latency ZGC.
Related Questions in Java
Advanced Java Interview Questions and Answers
Advanced level • 841 views
Java Web development interview questions
Advanced level • 664 views
Java Interview questions
Advanced level • 630 views
Java questions for Newbies
Intermediate level • 574 views
Interview questions on EJB
Advanced level • 454 views