What happens if Xmx is not used?

According to the JVM documentation, if you use the Xms argument too large, the JVM does not start. So, I ask, what happens if I do not use it? Is my virtual machine growing unlimitedly? Will he be stopped only when physical memory runs out?

+4
source share
2 answers

XMX is the maximum heap size.

What happens if I do not use it?

If omitted, it uses the default value. The default value depends on the version of the JVM and on which platform it works. Details of version 5 are given here .

By default, the following are selected on server class machines.

...

maximum heap size ΒΌ physical memory up to 1 GB

+4
source

If you do not specify -Xmx , you will get the default distribution for your operating system, your jvm, its parameters and version.

Given the number of things that can affect the value and the time required to navigate the documentation, it would be easier to ask your jvm.

For example, on my Linux system:

 $ java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version' uintx AdaptivePermSizeWeight = 20 {product} uintx ErgoHeapSizeLimit = 0 {product} uintx InitialHeapSize := 66328448 {product} uintx LargePageHeapSizeThreshold = 134217728 {product} uintx MaxHeapSize := 1063256064 {product} uintx MaxPermSize = 67108864 {pd product} uintx PermSize = 16777216 {pd product} java version "1.6.0_24" 

the default is -server , but with -client I get:

 $ java -client -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version' uintx AdaptivePermSizeWeight = 20 {product} uintx ErgoHeapSizeLimit = 0 {product} uintx InitialHeapSize := 16777216 {product} uintx LargePageHeapSizeThreshold = 134217728 {product} uintx MaxHeapSize := 268435456 {product} uintx MaxPermSize = 67108864 {pd product} uintx PermSize = 12582912 {pd product} java version "1.6.0_24" 

On my windows system, I get:

 C:\>java -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version" uintx AdaptivePermSizeWeight = 20 {product} uintx ErgoHeapSizeLimit = 0 {product} uintx InitialHeapSize := 16777216 {product} uintx LargePageHeapSizeThreshold = 134217728 {product} uintx MaxHeapSize := 268435456 {product} uintx MaxPermSize = 67108864 {pd product} uintx PermSize = 12582912 {pd product} java version "1.6.0_21" 

which are the -client settings and the -server option does not exist:

 C:\>java -server -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version" C:\>java -server -XX:+PrintFlagsFinal -version Error: no `server' JVM at `C:\jdk\jre\bin\server\jvm.dll'. 
+3
source

All Articles