Module: | Core Architecture, Basics & Control Flow
Q3: Consider the following statements regarding the Java Virtual Machine (JVM) Memory Architecture:
1. The Method Area is a shared runtime resource among all threads that stores class-level data, method definitions, and the runtime constant pool.
2. The Stack Area is a shared memory pool where all objects and their corresponding instance variables are dynamically allocated at runtime.
3. The Program Counter (PC) Register maintains a separate allocation for every thread to store the address of the currently executing JVM instruction.
Which of the above statements is/are correct?
2. The Stack Area is a shared memory pool where all objects and their corresponding instance variables are dynamically allocated at runtime.
3. The Program Counter (PC) Register maintains a separate allocation for every thread to store the address of the currently executing JVM instruction.
Which of the above statements is/are correct?
✅ Correct Answer: B
🎯 Quick Answer:
The correct combination is 1 and 3. Statement 2 is incorrect because objects are dynamically allocated in the Heap Area, not the Stack Area. The Stack Area is thread-specific and stores local variables and method call frames.Structural Breakdown: The JVM memory is logically divided into five components: Method Area (shared), Heap Area (shared), Stack Area (per thread), PC Register (per thread), and Native Method Stack (per thread). Historical/Related Context: In modern JVM implementations (specifically starting from Java 8), the Method Area's physical implementation changed.
The older 'PermGen' space was replaced by 'Metaspace', which resides in native system memory rather than the JVM heap, preventing common OutOfMemory errors associated with class loading.
Causal Reasoning: The architectural distinction between shared (Heap/Method) and per-thread (Stack/PC) memory is critical for Java's multithreading.
Shared areas allow multiple threads to access the same application objects, while isolated stacks prevent threads from corrupting each other's local execution state.