Reputation:
According to the documentation of the JVM, if you use too big of a Xms paramenter, the JVM won't start. So, I ask, what happens if I don't use it? Is my VM allowed to grow indefinitely? Would it stop only when physical memory runs out?
Upvotes: 11
Views: 7488
Reputation: 7944
If you don't specify -Xmx
then you will get the default allocation for your operating system, your jvm, it's options and version.
Given the number things that might affect the value and the time it takes to navigate the documenation, it might just be easier to ask your jvm.
For instance 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"
as it defaults to -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"
While 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 there appears to be no -server
option:
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'.
Upvotes: 5
Reputation: 141638
XMX is the max heap size.
what happens if I don't use it?
If it is omitted, it uses the default. The default varies by JVM version, and what platform it's running on. The details of version 5 are here.
On server-class machines by default the following are selected.
...
maximum heap size of ¼ of physical memory up to 1Gbyte
Upvotes: 9