What is the default maximum heap size for Sun's JVM from Java SE 6?

前端 未结 6 1137
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 18:38

What is the default maximum heap size for Sun\'s JVM from Java SE 6 (i.e. equivalent to setting -Xmx)?

Looks like for Java SE 5 with a server-class machine, it\'s

6条回答
  •  醉酒成梦
    2020-11-29 18:59

    To answer this question it's critical whether the Java VM is in CLIENT or SERVER mode. You can specify "-client" or "-server" options. Otherwise java uses internal rules; basically win32 is always client and Linux is always server, but see the table here:

    http://docs.oracle.com/javase/6/docs/technotes/guides/vm/server-class.html

    Sun/Oracle jre6u18 doc says re client: the VM gets 1/2 of physical memory if machine has <= 192MB; 1/4 of memory if machine has <= 1Gb; max 256Mb. In my test on a 32bit WindowsXP system with 2Gb phys mem, Java allocated 256Mb, which agrees with the doc.

    Sun/Oracle jre6u18 doc says re server: same as client, then adds confusing language: for 32bit JVM the default max is 1Gb, and for 64 bit JVM the default is 32Gb. In my test on a 64bit linux machine with 8Gb physical, Java allocates 2Gb, which is 1/4 of physical; on a 64bit linux machine with 128Gb physical Java allocates 32Gb, again 1/4 of physical.

    Thanks to this SO post for guiding me:

    Definition of server-class machine changed recently?

提交回复
热议问题