JVM Memory Management: Heap, Stack, Metaspace & Garbage Collection Internals
Explore Stack vs Heap memory allocation, Young Generation (Eden, Survivor S0/S1), Old Generation, Metaspace, G1GC, and ZGC Garbage Collectors.
JVM Generational Memory Heap Model
### JVM Memory Heap Architecture
1. **Young Generation**: Eden Space (where new objects are instantiated) + Survivor Spaces S0/S1. Minor GC collects short-lived objects.
2. **Old Generation**: Long-lived objects promoted after surviving N garbage collection cycles. Major/Full GC collects Old Gen.
3. **Metaspace**: Off-heap native memory storing class metadata, method bytecodes, and String Pool.