JVM Heap Regions and Object Lifecycle
Explore Young Generation (Eden, Survivor), Old Generation, and Metaspace and how objects move between them.
The JVM Memory Model
The JVM divides memory into several areas. The heap holds all class instances and arrays. Off-heap areas include Metaspace (class metadata), stack frames, and native memory.
Young Generation: Eden Space
Newly allocated objects go to Eden. When Eden fills up, a Minor GC runs. Surviving objects are copied to a Survivor space.
// Object allocation starts in Eden:
String s = new String("hello"); // allocated in Eden
List<Integer> list = new ArrayList<>(); // also EdenAll lessons in this course
- JVM Heap Regions and Object Lifecycle
- GC Algorithms: Serial, G1, ZGC, Shenandoah
- Detecting and Fixing Memory Leaks
- GC Tuning Flags and JVisualVM Profiling