Java run-time data region
The memory managed by the Java Virtual Machine includes the following runtime data regions, such as:
Program counter
Program Counter Register is a small area of memory that is the line number indicator of the byte code executed by the current thread. A program counter is a private area of memory where each thread has a separate program counter. If the thread is executing a Java method, this program counter records the executing virtual machine bytecode instruction address, or null (Undefined) If the native method is being executed. The memory area where the program counter resides is the only area where the Java virtual machine does not have an oom (outofmemoryerror) condition.
Java Virtual Machine stack
The Java Virtual machine stack is also thread-private, and the lifecycle is synchronized with the thread. The virtual machine stack describes the memory model that the Java method executes: Each method executes and creates a stack frame to store information such as the local variable table, the operand stack, the dynamic chain, the method exit, 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.
There are two exceptions to the memory area of the virtual machine stack:
1. The stackoverflowerror exception is thrown when the thread requests a stack depth greater than the allowed depth of the virtual machine;
2. An oom (Outofmemoryerro) exception is thrown when the application does not have enough memory to be expanded when the area is changed.
Java Memory Area