JVM memory Partition
JVMMemory Partition
This article attempts to discuss the situation of JVM memory partitions.
1.JVMThe relationship between memory and system memory
Is a rough description of the system memory and JVM memory
For most operating systems, the memory can be divided into two parts: Physical Memory RAM and Swap (Swap zone). Swap Space is physically an independent disk area. When the operating system finds that the memory is insufficient for use, then you start using the swap zone.
At the system level, the Linux system memory can be roughly divided:
After a JAVA program starts running, it is a process that exists on the system. The memory occupied by this process is managed by JVM.
2.JVMMemory Division
JVM memory can be divided into the following main parts:
Heap is the main battlefield for memory recovery. Therefore, it is called Garbage Collected Heap (GC Heap) under the generational collection policy. Heap can be further divided into the new generation and old generation, more detailed:
- Eden area. When an object is created for the first time, it opens up space from the Eden area.
- In the same vor area, when the Eden area is insufficient for the next memory allocation, the JVM triggers a GC. objects that have passed the GC but have not been recycled are transferred to the same vor area. The recovery VOR is divided into two parts: From and To. objects that are not recycled during Multiple Memory reclaim are transferred back and forth in these two areas.
- Old zone. when an object is not recycled after a certain number of GC operations, JVM transfers it to the Old zone.
4. The JVM Stack, Java Virtual Machine Stack, and thread private have the same lifecycle as the corresponding thread. When each method is executed, a Stack Frame is created to store information such as the local variable table, operand Stack, dynamic link, and method exit. The execution and completion of each method correspond to the process of Stack Frame in the Virtual Machine Stack. Generally, the JVM memory is roughly divided into stacks and stacks. The Stack refers to the JVM Stack.
5. Native Method Stack: local Method Stack. Similar to JVM Stack, local Method Stack corresponds to Native Method execution management.
In addition, the Memory required for running the program is opened in the JVM Memory space. You can also directly apply for system Memory (Directive Memory). However, the system Memory directly applied for is not managed by JVM garbage collection, its release is controlled by the system layer. Therefore, for JAVA programmers who do not pay attention to memory reclaim, it is easy to cause problems such as memory overflow.