Java heap Memory _young gener_old generation_ Cenozoic and old age __java

Source: Internet
Author: User

using JDK8

The heap in Java is the largest chunk of memory that the JVM manages, primarily for storing instance objects of various classes.

In Java, the heap is divided into two distinct regions: the Cenozoic (young) and the old. The New Generation (young) is divided into three areas: Eden, from Survivor, to Survivor.

The purpose of this division is to enable the JVM to better manage objects in heap memory, including allocation of memory and recycling.

The memory model for the heap is roughly:

default parameters in JDK8: (Windows platform)

See Links:

Http://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#BABHDABI

Http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Default value for parameter:

ratio (ratio; proportion; coefficient) -xx:newratio

-xx:newratio=ratio

Sets The ratio between generation sizes. By default, this option is set to 2. The following example shows to set theyoung/old ratio to 1:

-xx:newratio=1 -xx:survivorratio

-xx:survivorratio=ratio

Sets The ratio between Eden space size and survivor space size. By default, this option is set to 8. The following example shows to set theEden/survivor spaces ratio to 4:

-xx:survivorratio=4 -xmssize

Sets The initial size (in bytes) of the heap. This value must is a multiple of 1024 and greater than 1 MB. Append the letter K or K to indicate kilobytes, m or m to indicate megabytes, g or G to indicate gigabytes.

The following examples show how to set the size of allocated memory to 6 MB using various units:

-xms6291456

-xms6144k

-xms6m

If You don't set this option, then the initial size is set as the sum of the sizes allocated for the old generation And the young generation. The initial size of the heap for the young generation can is set using THE-XMN option or the-xx:newsize option. -xmxsize

Specifies the maximum size (in bytes) of the memory allocation pool in bytes. This value must is a multiple of 1024 and greater than 2 MB. Append the letter K or K to indicate kilobytes, m or m to indicate megabytes, g or G to indicate gigabytes. The default value is chosen in runtime based on system configuration. For server deployments,-XMS and-xmx are often set to the same value. For more information, you'll garbage Collector ergonomics at http://docs.oracle.com/javase/8/docs/technotes/guides/vm/ Gc-ergonomics.html

The following examples show how to set the maximum allowed size of allocated memory to MB using various units:

-xmx83886080

-xmx81920k

-xmx80m

THE-XMX option is equivalent to-xx:maxheapsize. -xx:maxheapsize=size

Sets The maximum size (in byes) of the memory allocation pool. This value must is a multiple of 1024 and greater than 2 MB. Append the letter K or K to indicate kilobytes, m or m to indicate megabytes, g or G to indicate gigabytes. The default value is chosen in runtime based on system configuration. For server deployments,-xx:initialheapsize and-xx:maxheapsize are often set to the same value. For more information, you'll garbage Collector ergonomics at http://docs.oracle.com/javase/8/docs/technotes/guides/vm/ Gc-ergonomics.html

The following examples show how to set the maximum allowed size of allocated memory to MB using various units:

-xx:maxheapsize=83886080

-xx:maxheapsize=81920k

-xx:maxheapsize=80m

the-xx:maxheapsize option is equivalent to-xmx.

By default, the value of the New Generation (young) is 1:2 (this value can be specified by parameter –xx:newratio), namely: The heap space size of the Cenozoic (young) = 1/3.

Age (old) = heap space size of 2/3. Among them, the Cenozoic (young) was subdivided into Eden and two Survivor regions, the two Survivor regions respectively named from and to, in order to differentiate.

The default,Edem:from:to = 8:1: 1 (can be set by the parameter –xx:survivorratio), namely: Eden = 8/10 of the Cenozoic space size, from = to = 1/10 of the Cenozoic space size.

TheJVM uses only Eden and one of the Survivor areas to serve the object at a time, so there's always a Survivor area free whenever you want.

Therefore, the new generation of real memory space is 9/10 (that is, 90%) of the Cenozoic space.

As shown in the following figure,

As shown in the following figure,

Turn from: http://www.codeweblog.com/java%E5%A0%86%E5%86%85%E5%AD%98_young-gener_old-generation_%E6%96%B0%E7%94%9F%E4% bb%a3%e5%92%8c%e8%80%81%e5%b9%b4%e4%bb%a3/

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.