Q35: What is the Java Memory Model layout (Stack vs Heap Memory Regions)?

  • JVM Stack: Each thread possesses an independent private execution stack. Stores local variables, primitive method parameters, and execution frame call stacks. Garbage Collector does NOT manage Stack.
  • JVM Heap: Shared memory region housing all created Object instances, arrays, and instance fields. Managed by the Garbage Collector.
JVM Memory Runtime Partitioning
Key Takeaways
  • Stack = Private per thread (primitive parameters, method frames). Heap = Shared across all threads (object allocations, instance fields).
Knowledge Check

Where is a local variable referencing an Object inside a method stored?