It is divided into the following runtime data areas:
Program counter, Java Virtual machine stack, local method Stack, Java heap, method area
Program Counter:
Thread private, log executing virtual machine bytecode instruction address, execute local method is empty, is the only Java virtual machine in memory without putofmemoryerror condition
Java Virtual machine stack:
The thread is private and the life cycle is the same as the thread, which is used to support the virtual machine for method invocation and method execution. For the execution engine, only the stack frame at the top is valid, called the current stack frame, and the associated method is the current method, and all byte instructions are only for the current stack frame operation.
There are two types of anomalies:
Throws a Stackoverflowerror exception when a thread requests a stack frame that is larger than the allowed depth of the virtual machine
Virtual machine cannot request enough memory space to throw OutOfMemoryError exception when dynamic expansion stack
Information stored in the stack frame:
Local Variables Table: Store method parameters and methods internally defined local variables, the type of data stored is the compilation period of the various basic data types, object reference and ReturnAddress type (point to a bytecode specified address), the required memory space at compile time to complete the allocation, That is, when the Java program is compiled into class, the capacity of the local variable table is determined, and the method does not change during operation. 32-bit one slot,64-bit sequential two slots
Operand stack:
Also known as the Operation Stack, the maximum depth is determined at compile time. 32 bits occupy one stack frame, 642. The Operation Stack provides support for various bytecode directives (plus and minus assignments)
The Java Virtual machine interpretation execution engine is called the "stack-based execution engine", which refers to the Operation Stack, also known as the Java Virtual Machine test stack-based. Android Register-based, faster, but poorly ported
Dynamic Connection:
Each stack frame contains a reference to the method that the stack frame that runs the constant pool (in the method area) belongs to, and holds the reference to support the dynamic connection of the method invocation procedure.
A constant pool has a large number of symbolic references, some of which are converted to direct references during the class load phase or the first use, called static parsing, and the other part is converted to a direct reference during each run, called a dynamic connection
Method return Address: Restores the local variable table of the upper method and the operand stack, and a return value pushes it into the operand stack of the caller's stack frame
Local method Stack:
Very similar to the Java Virtual machine stack, the virtual machine stack is the Java method service performed by the virtual machine, and the local method stack is used by the local operating system (Native) method service
Java heap:
is the largest chunk of memory managed by a virtual machine and is a chunk of memory shared by all threads. Almost all object instances and arrays allocate memory here, and are also the main areas of garbage collector management, also known as GC heap
Method Area:
All threads are shared to store the class information, constants, and static variables that have been loaded by the virtual machine, even after the compiler compiles the code such as data, also known as the permanent generation.
Running a constant pool is part of the method area, which holds the various literal and symbolic references generated by the compiler, and the class file Chang (the class version, field, method, interface, and other descriptive information) than the dynamic
Java Virtual machine memory allocation