Out of interest - Does a default exist or is it different on each OS?
If it does, what are the defaults? Incredibly hard to find!
Configure the default JRE Set it as the default in Eclipse by selecting Preferences -> Java -> Installed JREs. Add the installed JDK and select the checkbox, making it the default.
As Matt Solnit answered, the specifics for java 1.5 were 1GB or ¼ of physical memory, whichever is lower, for a server class machine and 64MB for other machines (from Java 5.0 Ergonomics documentation).
Unfortunately JVMs change over time and the most appropriate documentation gets more difficult to identify, so to find out the default heap (and PermGen heap) size for your specific JVM, the best way to find out is to get your JVM to tell you.
Somewhere between "1.6.0_06" and "1.6.0_21", the -XX:+PrintFlagsFinal
option was added, and it appears to have first come to peoples attention at around "1.6.0_23". It provides a wealth of information about how the JVM is configured, but we will concentrate on heap and permgen sizes and limits.
On Linux you can use the command:
java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
Similarly on windows, you can use the command:
java -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version"
java
may default to either -client
or -server
, so if you force your application to start with either of these, you can also do the same when you start these commands.On my Linux system, I get:
$ 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"
and it defaults to -server
, so 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 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'.
To summarise:
Parameter \ JVM 1.6.0_24
Lin/svr Lin/cli Windows
InitialHeapSize 63MB 16MB 16MB
LargePageHeapSizeThreshold 128MB 128MB 128MB
MaxHeapSize 1014MB 256MB 256MB
MaxPermSize 64MB 64MB 64MB
PermSize 16MB 12MB 12MB
You can find the details in the Java 5.0 Ergonomics documentation. Specifically:
According to java documentation the default for the Sun/Oracle Windows and Solaris/Linux JVMs are 64MB. This could be different for different JVM vendors though. For example, the default -Xmx value for JRockit is the lesser of 75% of the total amount of memory or 1GB.
If you are curious about what maximum amount of memory you can use on your JVM, at runtime you can call:
System.out.println(Runtime.getRuntime().maxMemory());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With