This article mainly introduces the contents of the JVM Runtime data area.
Let's take a look at what's shown here. The JVM runtime data area is mainly divided into two main parts: The method area of the thread common and the heap (heap), the thread-private virtual machine stack (VM stack), the local method stack (Native), and the program counter Counter Register). The execution engine below the data area also contains the following: the Instant compiler (Jitcompiler) and the garbage collector (GC). GC is primarily used to reclaim thread-shared areas (method areas and heaps), and the system is automatically freed for private memory areas when the method is finished. (In the actual program, the thread private memory area will have many copies)
For the entire runtime data area, the modules for external interaction are the execution engine, the local library interface, and the ClassLoader.
JVM Runtime data area (picture source)
The details of each memory area are described below.
1, program Counter Register [ Private]): is a small memory space, its role can be seen as the current thread is executed by the line number indicator of the byte code. ① (This memory area is the only area that is not specified in the JVM specification for any outofmemoryerror)
2. JVM Stack (Java Virtual machine Stacks [private]): Each method will create a stack frame at the same time when executing. The JVM stack contains information such as local variable tables, operation stacks, dynamic links, method exits, and so on.
3, the Local method stack (Native methods Stacks [Private]): Its memory structure is similar to the JVM stack, but the use of the local library interface.
4. Heap (heap [shared]): The heap area is the largest chunk of the JVM's memory management, and almost all objects that come out of new are placed in this area. During GC, most of the memory recycling occurs in this area.
5. Method area [Shared]: The method area is mainly used to store the class information loaded by the JVM, constants, static variables, immediately compiled code, and so on.
6. Run a constant pool (runtime Constant pool [method Area component]): Used to hold various literal and symbolic references generated by the compiler.
JVM run-time data area