The Java memory area can be divided into two main categories:
1, thread-sharing:
Method Area: Thread sharing, which stores data such as class information, constants, static variables, and code compiled by the instant compiler that have been loaded by the virtual machine. It is described as part of the heap by the virtual machine specification. are also considered "permanent generations".
Run constant: Part of the method area;
Heap: So threads are shared; Almost all object instances, arrays are allocated memory on the heap (JIT technology can not allocate memory on the heap, such as stacks), can be physically discontinuous, there may be a thread-private thread buffer assigned to each thread (thread Local
Allocation Buffer, Tlab); The heap traffic is also divided into the primary generation, the elderly generation;
Execution Engine:
Local Interface Library:
Direct Memory: A part of the data area that is not a virtual machine, or an area of memory defined in the Java VM Specification, may also cause memory exceptions, and the memory inside is out-of-heap memory.
2, the thread exclusive:
Virtual machine stack: The life cycle is the same as the thread, where the local variable table holds the underlying type data or the object's reference, and if the thread requests a stack depth that exceeds the depth of the virtual machine's run, Stackovermemoryerror is thrown;
Local method Stack: similar to the virtual machine stack, even some virtual machines do not distinguish between the two.
Program Calculator: The line number indicator of the current thread execution byte code, used by the bytecode interpreter to select the next execution instruction. Consumes little memory and is used only for Java code.
Object Memory Layout:
1. Object: Consists of three parts, object header (header), instance data (Instance), aligned padding (padding)
2. Object Head:
A, a part is used to store its own runtime data, including hash code (25BIT), GC generational age (4bit), lock status Tag (2bit), thread-held lock, biased thread ID, biased time stamp;
B, part of the type pointer, the class metadata that points to it
Java memory area and memory overflow