Summary of common memory areas in Java:
< development Combat Classic >
(1) Stack memory space: Save All object names
(2) Heap memory space: Save specific property content for each object
(3) Global Data area: Saving properties of static type
(4) Global Code area: Save All method definitions
< instructor >
(1) Stack area: Store local variables
(2) Heap area: Store object properties, new data
(3) Method area: Store and class-related information
(4) Local method area: System-dependent, no programmer management required
(5) Register: CPU-dependent, no programmer management required
< in-depth understanding of Java Virtual machines >
(1) Procedure Counter (Program counter register):
A small amount of memory space that can be thought of as the line number indicator of the byte code executed by the current thread (thread private). The bytecode interpreter works by changing the value of this counter to select the next byte-code instruction to execute.
(2) Java Virtual machine stack (VM stack):
Also thread-private, the lifecycle is the same as the thread, and the virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame to store the local variable table/operand stack/dynamic link/ Method export information. Each method from the call to completion of the process corresponds to a stack frame in the virtual machine stack from the stack to the stack.
(3) Local methods stack (native method stack):
Similar to the virtual machine stack, the difference is that the virtual machine stack executes the Java method service, and the local method stack executes the local (native) method service.
(4) Method area:
Shared with the heap by all threads, used to store data such as class information/constants/static variables/instant compiler compiled code that have been loaded by the virtual machine, also called non-heap (non-heap), also known as "permanent generation". Includes a runtime constant pool
--run a constant-volume pool (runtime constant):
In addition to descriptive information such as the Version/Field/method/interface of the class, there is a constant pool that holds the various literal and symbolic references generated by the compiler.
(5) Heap:
The largest area in memory, shared by all threads. The function is to store all object instances and arrays (regardless of the escape analysis technology). The heap is also a major area of GC management, so it is also called a "gc heap", so the Java heap can be subdivided into a collection of generational and older generations ( More detailed: Eden Space-from survivor space-to Surviver space). From the memory allocation perspective, the thread-shared Java heap may divide multiple thread-private allocation buffers (Tlab).
Java Memory Area Summary