VM conceptual model
1: a program counter (Program Counter Register)
(1) metaphor: the thread can be seen as a byte code executed by the display line number
(2) the relationship between threads: each thread has its own program counter
(3) the role of: storing virtual machine bytecode instruction address is currently executing thread
2: Stack Virtual Machine (VM Stack)
The stack frame
(1) Definition: From each method call, creates a stack frame for storing information local variable table, the operand stack, dynamic link, the method exports. Each method call from the end, which corresponds to a frame on the stack and out of the stack into the stack.
(2) StackFlowOverError: thread request stack depth exceeds the depth of the stack of the virtual machine is allowed.
(3) OutOfMemoryErro: not enough memory to apply to the virtual machine dynamic expansion.
3: native method stacks (Native Method Stack)
(1) and virtual machine stack different places
· Virtual machine is Java execution stack service (bytecode service)
· Native method stacks Native method is executed service.
Native method on the fly by wire voice Java Java interface, Native method as implemented in C ++.
Both similar
(2) the virtual machine and the same stack, and an OutOfMemoryError will be thrown StackOverflowError.
4: Java heap ( "garbage" -Heap)
(1): All threads share.
(2): When you create a virtual machine starts.
(3): The main management area garbage collector (GC main work area).
The only purpose is to store the object instance.
(4): can be divided into the old and the new generation's, the new generation can be divided into Eden area, From Survivor area, To Survivor region. The default ratio of 8: 1: 1.
FIG: After generating the new generation of A, B, C three objects.
1st GC: recovered out A, B and C will move from Eden From zone to zone.
The second GC: recovery off B, C twice since neither can be recovered, thus transferred to the To area.
3rd GC: C still could not be recovered, will be transferred to From To District area.
4th GC: C transferred to and from the region From To area, so repeated 15 times, if C is still unable to be GC ....
16th GC: From this point C should be in the area, will be moved to the old era.
4: Area Method (Method Area)
(1): Like the Java heap, all threads share.
(2): a virtual machine for storing class information loaded, a constant, static variables, the real-time data such as the code compiler.