Program counter
- An indicator of instruction execution.
- Each thread has a separate program counter that has no effect on each other, and we call this zone a thread-private memory.
- Executes the Java method, the counter records the executing virtual machine bytecode instruction address, if the native method is executed, this counter is empty.
- The only area in this memory area that does not have any outofmemoryerror defined.
Virtual Machine Stack
- The Java Virtual machine stack is also thread-private, with the same life cycle as the thread.
- The virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame to store local variable tables, operand stacks, dynamic links, method exits, and so on.
- If the thread requests a depth greater than the virtual machine depth, the Stackoverflowerror exception is thrown, and if the virtual machine can be dynamically extended, the extension cannot request enough memory to be thrown outofmemoryerror.
Local method Stack
and the virtual machine stack is very similar, the difference between them is that the local method stack is for the virtual machine to use the native method service, and the virtual machine stack is to perform Java method service for the virtual machine.
Java heap
- The Java heap is the largest piece of memory managed by the virtual machine.
- A piece of area that is shared by all threads.
- The only purpose of this memory is to hold an instance of the object.
- Garbage collection manages the main areas.
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 immediately compiled code that have been loaded by the virtual machine.
Run a constant-rate pool
- Running is a constant pool that is part of the method area.
- Used to hold various literal and symbolic references generated during the compilation period.
- Running a constant pool is not the same as the class file constants pool. The Java language does not require a class file constant at compile time to enter the run-times pool, and new constants may be placed in the pool during run time. This feature is used by developers for the Intern () method of the String class.
Java Memory Area