6 · Advanced · lesson 38 of 41

JVM Memory Model

Heap, stack, metaspace and how they interact.

  • ▸Stack — one per thread; primitives and references live here.
  • ▸Heap — shared across threads; all objects live here.
  • ▸Metaspace — class metadata, bytecode, method info.
  • ▸PC register + native method stack — bookkeeping per thread.
TIP
The 3D scene highlights the boundary: primitives are on the stack, objects float in the heap.
Loading 3D scene…
Key takeaways
  • ✓Each thread gets its own stack.
  • ✓Only the heap is garbage-collected.