JavaVirtualMachine is a program/software that receives Java bytecode (.class file) and convert the bytecode (line by line) into machine understandable code.
The JVM contains a module called a class loader. The class loader in the JVM is responsible for loading, linking, and initializing programs. It:
Loads the class into memory.
Verify bytecode instructions.
Allocate memory for the program.
JVM has five memory locations, which are:
Heap- Allocate runtime storage for objects (reference types).
Stack- Stores local variables and partial results. The stack contains frames, and each thread is allocated one frame. After the thread completes, the frame is also destroyed. It also plays a role in method calls and returns.
PC Register- The Program Counter register contains the address of the instruction currently executed by the JVM.
Execution Engine- It has a virtual processor, an interpreter that interprets bytecode instructions one by one, and a just-in-time compiler.
Native Method Stack- It contains all the native methods used by the application.
The above is the detailed content of In Java, how many types of memory areas are allocated by the JVM?. For more information, please follow other related articles on the PHP Chinese website!