Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 887
Liping Huang Avatar asked Dec 23 '13 08:12

Liping Huang


1 Answers

-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.

like image 142
piet.t Avatar answered Sep 24 '22 07:09

piet.t