The Java Virtual machine executes the Java program by dividing the memory it manages into a number of different data regions, called the runtime data areas.
Program counter
A program counter is a small amount of memory space that can be thought of as the line number indicator of the byte code executed by the current thread. Each thread needs to have a separate program counter, and the counters between the threads do not affect each other and are stored independently.
Java Virtual Machine stack
The virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame to store information such as local variable tables, operand stacks, dynamic links, method exits, and so on. Each method from the call until the completion of the process, corresponding to a stack frame in the virtual machine stack into the stack of the process.
Local method Stack
The local method stack is similar to the virtual machine stack, and the local method stack is the native method service that is used for the virtual machine.
Java heap
The Java heap is a piece of memory that is shared by all threads and created when the virtual machine is started. The only purpose of this memory area is to hold object instances where almost all object instances are allocated memory.
Method area
The method area, like the Java heap, is an area of memory shared by each thread that stores data such as class information, constants, static variables, and code compiled by the immediate compiler that have been loaded by the virtual machine.
Reference
1, Zhou Zhiming, in-depth understanding of Java Virtual machines: JVM advanced features and best practices, mechanical industry Press
Java memory model