"Go" JVM memory model

Source: Internet
Author: User

http://longdick.iteye.com/blog/473866

Diagram of the JVM memory model Blog Category:
    • Jvm
JVM Activity Sun

/**

* Reprint Please indicate author Longdick http://longdick.iteye.com

*

*/

The Java memory model consists of 3 generations, and the default permutations of each generation are as follows (for jdk1.4.* to JDK6):


The memory model of Java is divided into

Young (younger generation)

Tenured (lifelong generation)

Perm (permanent Generation)

Some old versions are also known as

New

Old

Perm

The meaning of the expression is basically the same.

Note that young (younger generation) can also be divided into the Eden area and two survivor zones (from and to, these two survivor areas are strictly one to the size), and new object instances are always first placed in the Eden area, The survivor Zone acts as a buffer for the Eden and tenure (lifetime Generations) , and can transfer the active object instances to the tenure (Lifetime generation).

Tenure (Lifetime generation) holds a long-lived instance object, but it is not as life-like as its name, and the objects in it are still recycled.

Young and tenure together make up a heap of memory.

Perm (permanent generation) is part of the non-heap memory. The main storage is loaded class class object such as class itself, Method,field and so on.

Some students may have noticed that each generation has a virtual area is what?

We know that there are some parameters that can affect the size of each of these generations.

When the JVM starts, it retains a fixed amount of memory to the heap memory, which is not necessarily used by the JVM, but it can be determined that this portion of the reserved memory is not used by other processes. This part of the memory size is determined by -Xmx 参数指定。

In the other part, the JVM is allocated to the JVM when it is started, and is used as the JVM's initial heap memory. The parameter that affects this is -xms, if the value specified by-XMS is smaller than-xmx, then the difference between the two is virtual memory value. As the program runs, the Eden, tenured, and perm areas will gradually use the reserved virtual space.

If unspecified, the initial and maximum heap memory is calculated based on the machine's memory. Parameters DefaultInitialRAMFraction and DefaultMaxRAMFraction will affect the final result, as shown in the following table:


Formula Default
Initial Heap Size memory / DefaultInitialRAMFraction memory /64
Maximum Heap Size MIN(memory / DefaultMaxRAMFraction, 1GB) MIN(memory/ 4, 1GB)

You can see that the default value of heap memory is no more than 1G.

The JVM automatically determines when to expand and reduce the actual heap memory size based on the usage of the heap memory, which can be used with VM parameters -XX:MinHeapFreeRatio=<minimum> and -XX:MaxHeapFreeRatio=<maximum> 使用堆内存空闲百分比来定义,一般在32位机器上的默认值如下:

Parameter Default Value
MinHeapFreeRatio 40
MaxHeapFreeRatio 70
-Xms 3670k
-Xmx 64m

When the free heap memory percentage of heap memory is less than 40%,JVM, it attempts to expand the heap memory space and attempts to compress the heap memory space when the percentage of heap memory occupied by the free heap memory is higher than 70%,JVM.

PS: The above default values will have different values on different platforms, and if it is a 64-bit system, these values typically need to be expanded by 30% to accommodate objects that become larger under the 64-bit system.

Plus -XX:NewRatio=3 that means young (younger generation) and tenured (lifetime generations) are 1:3, meaning that the sum of the Eden and survivor areas will account for 1/4 of the total heap of memory.

加上-XX:SurvivorRatio=6The ratio of setting Eden area to one of survivor space is 1:6, that is, one survivor space represents the capacity of the younger generation 1/8 (you can think about why not 1/7).

In addition, there are-XX:NewSize -XX:MaxNewSize  指定年轻代的初始值和最大值。

The default values for 32-bit systems are as follows:


Default Value Parameter Client JVM Server JVM
NewRatio 8 2
NewSize 2228K 2228K
MaxNewSize not limited not limited
SurvivorRatio 32 32

Extended reading:

Diagram JVM Application object in memory and garbage collection process

Three kinds of GC big secret

Resources:

Http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html

"Go" JVM memory model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.