VM Memory Model:
Thread private
1. Program countersThe ProgramCounter Register (ProgramCounter) is a small memory space. Its function can be seen as the row number indicator of the bytecode executed by the current thread.
2. Java Virtual Machine StackWhen each method is executed, a Stack Frame is created at the same time to store information such as the local variable table, Operation Stack, dynamic link, and method exit.
3. Local method StackThe local method stack is the Native method service used by virtual machines.
Thread sharing
4. HeapThe only purpose of this memory area is to store object instances, where almost all object instances allocate memory.
5. Method AreaIt is used to store data such as class information, constants, static variables, and Code Compiled by the real-time compiler loaded by virtual machines.
6. Direct MemoryThe NIO (New Input/Output) class is added to JDK 1.4, and an I/O Method Based on Channel and Buffer is introduced, it can use the Native function library to directly allocate off-heap memory, and then use a DirectByteBuffer object stored in the Java heap as a reference to this memory.
Local variable tableVarious basic data types (boolean, byte, char, short, int, float, long, and double) and object references (reference type, reference pointer, handle or other locations related to the object) and returnAddress type (pointing to the address of a bytecode instruction)
Runtime constant pool(Runtime ConstantPool) is part of the method area. In addition to the description of the version, field, method, and interface of the Class, the Class file also contains the Constant Pool Table ), it is used to store various types of literal and symbolic references generated during the compilation period. This part of content will be stored in the runtime pool of the method area after the class is loaded.