1. Data Region division at runtime
2. Program counter
Function: Can be seen as the line number indicator of the byte code executed by the current thread.
Explanation: The bytecode indicator specifies the next instruction to be executed by changing the value of the program counter. The basic functions of branching, looping, etc. are dependent on the program counter to complete.
Note: Because the multithreading of a Java Virtual machine is done by rotating and allocating processor execution time, a single processor executes only one thread of instruction at a time. In order to recover the correct execution location after a thread recovery, each thread needs a separate program counter to ensure that the threads do not affect each other. So the program counter is "thread-private" memory.
Note: The program counter area is the only area in the Java virtual machine that does not have a OutOfMemory exception defined
3. Java Virtual machine stack
Role: The virtual machine stack describes the memory model that the Java method executes
Note: When each method is executed, a stack frame is created for storing local variable tables, operations stacks, dynamic links, method exits and other information. The process by which each method is called corresponds to a stack frame in the virtual machine stack from the stack to the stack.
Exception: (1) The stack depth of the thread request is greater than the stack depth allowed by the virtual machine, and Stackoverflowerror will be thrown.
(2) Virtual machine stack space can be dynamically extended, when dynamic expansion is unable to request enough space, throw OutOfMemory exception.
Note: The Java Virtual machine stack is also thread-private, with the same life cycle as the thread
4. Java Local method stack
Description: The local method stack and the Java stack function and principle are very similar. The difference is simply that the Java stack is for the Java Method service, while the local method stack serves the local method (Native). In the JVM specification, the specific implementation method and data structure of local development are not enforced, and the virtual machine is free to implement it. Combine the local method stack and the Java stack directly in the hotsopt virtual machine
Note: Stackoverflowerror and OutOfMemory exceptions are also thrown in the local method stack.
5. Java Heap
Role: The heap in Java is the largest memory space managed by the JVM and is primarily used to store instance objects of various classes.
Description: In Java, the heap is divided into two different zones:
(1) Cenozoic (Young). The New Generation (young) is divided into three regions: Eden, from Survivor, to Survivor
(2) The old age.
Purpose: The purpose of this division is to enable the JVM to better manage the objects in the heap memory, including the allocation of memory and recycling. Note: The area of memory shared by each thread
6. Method area, run-time constant pool, direct memory
(1) The method area is also a thread-shared area for storing class information, constants, static variables that have been loaded by the virtual machine
(2) running a constant-rate pool is also part of the method area.
(3) Direct memory is not part of the data area when the virtual runtime is running, nor is it a memory area defined in the Java Rapid Spec. Note: The OutOfMemoryError exception will be thrown when the method area, direct memory fails to meet the memory allocation requirements.
Java Automatic memory management mechanism