Why is the JVM total allocated memory greater than -Xmx?
Asked Answered
P

1

7

The JVM options:

-Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8

As expected, the JVM will allocate almost 20MB memory for the JVM heap.

But please see the following GC detail:

PSYoungGen total 9216K, used 4612K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
eden space 8192K, 56% used [0x00000000ff600000,0x00000000ffa812d8,0x00000000ffe00000)
from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
to space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)
PSOldGen total 10240K, used 8192K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
object space 10240K, 80% used [0x00000000fec00000,0x00000000ff400020,0x00000000ff600000) PSPermGen total 21248K, used 3033K [0x00000000f9a00000, 0x00000000faec0000, 0x00000000fec00000)
object space 21248K, 14% used [0x00000000f9a00000,0x00000000f9cf6708,0x00000000faec0000)

The size of the young generation is as expected for the option -Xmn. The ratio of size for eden space and survivor spaces in the young generation is as expected for the option -XX:SurvivorRatio=8. But it seems in total the JVM allocated almost 40MB memory, so it is strange. Why is the JVM total allocated memory greater than -Xmx?

Env:

OS: win7 64 bit

JDK: build 1.6.0_43-b01 64bit

Protochordate answered 23/12, 2013 at 8:30 Comment(0)
W
11

-Xmx sets the maximum size of the HotSpot Object-Heap, that is the sum of YoungGen (Eden + Survivor-spaces) and OldGen and that is about 20 MB. The permanent generation resides outside this heap in a separate memory-area that is controlled via the -XX:MaxPermSize option.

Waggery answered 23/12, 2013 at 8:38 Comment(5)
so means the heap is devided into two generations: YoungGen and OldGen, not contains the PermGen?Protochordate
@LipingHuang Yes, that is correct. The heap is divided into the young generation, PSYoungGen, and the old generation, PSOldGen. The heap does not contain the permanent generation, PSPermGen. By the way, PS stands for parallel scavenge collector (enabled using -XX:UseParallelGC).Strawberry
@LipingHuang The young generation is further divided into the eden space and two survivor spaces known as the from space and to space. However, only one of the survivor spaces contributes to the stated size of the young generation, as discussed here.Strawberry
@LipingHuang In case you are wondering why the total heap size (PSYoungGen total 9216K + PSOldGen total 10240K = 19456K = 19MB) is less than the minimum heap size specified with -Xms20M then see the discussion here.Strawberry
@Strawberry The link post is removed. Any other references?Cheder

© 2022 - 2024 — McMap. All rights reserved.