What are the default -Xmx and -Xms values?

Happened to read Inspecting HotSpot JVM Options and found a solution to one of the questions that I have every now and then. What are the default -Xmx and -Xms values for this JVM on this machine? The solution? Invoking java with some flags, check out the terminal session.

toomasr@cigarillo-2:~$ java -server -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version | grep -i heapsize
uintx ErgoHeapSizeLimit                    = 0                {product}
uintx InitialHeapSize                     := 65011712         {product}
uintx LargePageHeapSizeThreshold           = 134217728        {product}
uintx MaxHeapSize                         := 1040187392       {product}
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
toomasr@cigarillo-2:~$ java -client -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version | grep -i heapsize
uintx ErgoHeapSizeLimit                    = 0                {product}
uintx InitialHeapSize                      = 0                {product}
uintx LargePageHeapSizeThreshold           = 134217728        {product}
uintx MaxHeapSize                          = 130862280        {product}
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)

If there is an easier way, let me know. Will put this one on my tool belt at the moment.

  • Mart

    Thanks often wanted to find this out. It works well for Java version “1.6.0_22″ and “1.6.0_23″ but unfortunately fails with “1.6.0_07″ we have the following error :-

    java -server -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version | grep -i heapsize
    Unrecognized VM option ‘+PrintFlagsFinal’
    Could not create the Java virtual machine.

  • http://twitter.com/toomasr Toomas Römer

    Wow, this sucks. Went over the Java 5 options and could not find an equivalent. I guess this only works for latest Java 6 builds.

  • Pingback: Intel i7: Corsair CMX8GX3M4A1600C9 XMS3 8 GB PC3-12800 Core i5 Memory Kit

  • Zahid1705

    this only works for Java 6u20 and later