Last Updated: June 6, 2026
When a Java program runs, the JVM carves up memory into several distinct regions, each with its own job. The two regions most discussed are the heap and the stack, but there are three more that do important work: the method area (also called Metaspace since Java 8), the PC register, and the native method stack. This lesson covers what each region holds, why the JVM splits memory this way, and what happens when one of them fills up. The location of every variable, every object, and every method call frame in a small program should be clear after reading.
The previous lesson introduced the Java Memory Model as a contract between threads and memory. This lesson focuses on the physical layout: the actual buckets the JVM uses to store data while code runs. Knowing the layout turns vague performance advice ("avoid allocating in tight loops", "watch out for stack depth") into something concrete.