Five regions of the Java virtual machine is running

Five regions JAVA virtual machine runtime

1. Program Counter

(1) a small memory space, the line number indicator at the time of execution of the program, rely on it to select the next instruction to be executed.

(2) thread private area.

(3) the method java thread execution, the counter records the address of the virtual machine bytecode instructions being executed.

(4) not only outofmemoryerror memory area.

2. VM stack

(1) thread private area, the life cycle of the same thread.

Java memory model is a method performed in (2) below.

While (3) each execute java method, creates a stack frame for storing local variable table and the like.

(4) from each java method call to complete the execution, the stack frame corresponds to the process to push the stack in a virtual machine stack.

(5) the thread requests stack depth greater than the depth permitted, throw exception stackoverflowerror.

(6) If the virtual machine stack dynamic expansion and extension requests can not be enough space to throw stackoverflowerror exception.

3. The native method stacks

And the java virtual machine stack effect is almost the same, except for the java virtual machine stack service method, native method stacks for the native method service. native method is used when using the joint development with C ++, java developers do not have their own native method.

4. heap

(1) to be shared by all threads.

(2) the only purpose is to store object instance.

(3) Garbage collection (Garbage collected) primary zone.

(4) If there is no heap memory to complete the instance distribution, and the heap can not be extended, it will throw outofmemoryerror exception.

The method area

(1) to be shared by all threads. (2) class information storage has been loaded virtual machine, constants and static variables. (3) can not implement garbage collection, not good, but sometimes have to collect, it may be some problems. (4) When the method of memory allocation area can not meet demand, an exception will be thrown outofmemoryerror.

 

Published 415 original articles · won praise 434 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_41901915/article/details/103499294