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

1 Answer 1

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.

5
  • so means the heap is devided into two generations: YoungGen and OldGen, not contains the PermGen? Commented Dec 23, 2013 at 9:30
  • @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). Commented Feb 9, 2015 at 9:35
  • @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. Commented Feb 9, 2015 at 9:39
  • @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. Commented Feb 9, 2015 at 9:45
  • @DontDivideByZero The link post is removed. Any other references?
    – Lebecca
    Commented Oct 12, 2021 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.