How to identify default Java heapsize in Windows

You can use -XX:+PrintFlagsFinal to print out a huge list of internal options to the JVM once all command line arguments and defaults have been processed. The -Xms option corresponds to InitialHeapSize, and the -Xmx option corresponds to MaxHeapSize.

To find the default maximum heap size that the JVM is using on Windows, run:

javaw -XX:+PrintFlagsFinal | find "MaxHeapSize"

To find the default initial heap size, run:

javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"

To answer the below query of vr3w3c9

Query raised by vr3w3c9: Hi, Thanks for the response. I tried to execute the above command javaw -XX:+PrintFlagsFinal | find "InitialHeapSize" in the command prompt, the value is not getting displayed. Im getting a popup message which says:

could not create the java Virtual Machine – vr3w3c9 Sep 27 '13 at 4:54

Answer: In Windows machine, Please run/open the Command Prompt (Windows Command Processor) as Administrator and execute the command you have mentioned. you will get the result as shown below:

C:\windows\system32>javaw -XX:+PrintFlagsFinal | find "MaxHeapSize"

uintx MaxHeapSize                              := 2122317824      {product}

C:\windows\system32>javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"

uintx InitialHeapSize                          := 132531136       {product}

Here, the unit of MaxHeapSize and InitialHeapSize is bytes.


Use JConsole. It is shipped with the JDK. You will find it's executable in the corresponding bin directory.


try below command for detailed result

java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"

result is

C:\Users\amar.magar>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"
 intx CompilerThreadStackSize                   = 0                                   {pd product}
uintx ErgoHeapSizeLimit                         = 0                                   {product}
uintx HeapSizePerGCThread                       = 87241520                            {product}
uintx InitialHeapSize                          := 268435456                           {product}
uintx LargePageHeapSizeThreshold                = 134217728                           {product}
uintx MaxHeapSize                              := 4271898624                          {product}
 intx ThreadStackSize                           = 0                                   {pd product}
 intx VMThreadStackSize                         = 0                                   {pd product}

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)