Run-time data region
(1) Procedure Counter (Program counter Register)
A small piece of memory space
The line number indicator of the byte code executed by the current thread, and the bytecode interpreter chooses the next hop to execute by changing the value of the program counter at work.
In multi-threaded environment, the thread switches execution, the program counter ensures that the thread can be restored to the correct position after switching.
Each thread has a separate program counter
Thread Private
Without any exceptions
(2) Virtual machine stack (stack)
The virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame during execution to store information such as local variable tables, operand stacks, dynamic links, method exits, and so on.
The local variable table holds various data types that are known during compilation: Boolean byte char short int float long double object reference (long and double occupy two local variable space slots)
The size of the local variable table is determined during compilation
Thread Private
Stackoverflowerror: The depth of the thread request stack is greater than the stack allowed by the virtual machine
Outofmemoryerror:java the virtual machine stack is not able to request enough memory when dynamically expanding
(3) Local method stack
Virtual machine Stack executes Java method services for virtual machines
The local method stack executes the native method service for the virtual machine
(4) Heap
Thread sharing
Store all instance objects and arrays
The largest chunk of the Java memory area
Main area of garbage collection (GC heap) (garbage collected)
Heap memory can be a physically discontinuous storage space, logically contiguous
OutOfMemoryError: Unable to get enough memory for heap memory expansion
(5) Method area
Thread sharing
Store class information, constants, static variables that have been loaded by the virtual machine, even after the compiler compiles the code
OutOfMemoryError: When the method area does not meet the requirements of memory allocation
(6) running a constant-rate pool
Part of the method area
class file In addition to the description of the version, field, method, interface, and so on, there is a constant pool (constant pool table), which holds the various literal and symbolic references generated during compilation
Store after class is loaded
In addition to saving the symbolic references described in the class file, the translated direct references are also stored in the constant pool
OutOfMemoryError
Java Runtime data region (stack method area constant pool)