JVM Runtime Data Area

Program Counter Register

The program counter is a relatively small memory space that can be viewed as an index of the bytecode row currently being executed by a thread. The bytecode interpreter works by changing the value of this counter to select the next bytecode instruction to execute; functions such as branches, loops, jumps, exception handling, and thread restoration all rely on this counter to complete their tasks.
Additionally, in order for threads to resume at the correct execution point after switching, each thread must have its own independent program counter. The counters of different threads do not affect one another and are stored independently; we refer to such memory regions as "thread-private" memory areas.

Java Virtual Machine Stack (JVM Stack)

The JVM stack describes the memory model for executing a Java method: every time a method is executed, the Java virtual machine synchronously creates a stack frame to store information such as local variable tables, operand stacks, dynamic links, and exit points of methods.

Native Method Area

The native method area plays a role very similar to that of the JVM stack; the only difference is that the JVM stack serves the execution of Java methods (i.e., bytecode) by the virtual machine, while the native method area serves local (native) methods used by the virtual machine.

Method Area

The method area stores data such as constants loaded into the virtual machine, static variables, class information (class version, fields, methods, interface descriptions), and code caches compiled by the JIT compiler.

Heap

The Java heap is a memory region shared by all threads and created when the virtual machine starts up. The sole purpose of this memory area is to store object instances; almost all object instances and data in Java are allocated on the heap.