The project manager asked me about the Java memory region model! in a hurry

That's it

Java memory area is mainly divided into three parts: heap, stack, and method area

1. Heap: The largest part of the memory area, shared by all threads, where created objects and arrays are stored. Since the heap is the main area managed by the garbage collector, it is also called the GC heap.

2. Stack: The thread is private, and it lives and dies with the thread. That is, each thread JVM will create a stack of memory for it.

Stack memory is further divided into: virtual machine stack, native method stack, and program counter

The virtual machine stack is used to describe the execution process of Java methods. The execution of each method corresponds to the push of a stack frame, and the return of the method corresponds to the pop of the stack frame.

The local method stack is similar to the virtual machine stack, the difference is the Native method service at the end of the local method stack. Native methods are also methods of non-Java code, generally the underlying C/C++ methods

The program counter occupies a small space and is used to record the line number indicator of the bytecode executed by the thread. Generally speaking, it is to record the execution position of the current thread, so that the thread can be restored to the original position after switching.

3. Method area: also known as permanent generation, which mainly stores constants, static variables, and class information.
The constants are stored in the memory area model data in the runtime constant pool

Finally, I wish everyone an early success in learning and a satisfactory offer

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324122964&siteId=291194637