On Windows, you can use the following command to find out the defaults on the system where your applications runs.

java -XX:+PrintFlagsFinal -version | findstr HeapSize

Look for the options MaxHeapSize (for -Xmx) and InitialHeapSize for -Xms.

On a Unix/Linux system, you can do

java -XX:+PrintFlagsFinal -version | grep HeapSize

I believe the resulting output is in bytes.

Answer from stones333 on Stack Overflow
Top answer
1 of 10
669

On Windows, you can use the following command to find out the defaults on the system where your applications runs.

java -XX:+PrintFlagsFinal -version | findstr HeapSize

Look for the options MaxHeapSize (for -Xmx) and InitialHeapSize for -Xms.

On a Unix/Linux system, you can do

java -XX:+PrintFlagsFinal -version | grep HeapSize

I believe the resulting output is in bytes.

2 of 10
130

For Java SE 5: According to Garbage Collector Ergonomics [Oracle]:

initial heap size:

Larger of 1/64th of the machine's physical memory on the machine or some reasonable minimum. Before J2SE 5.0, the default initial heap size was a reasonable minimum, which varies by platform. You can override this default using the -Xms command-line option.

maximum heap size:

Smaller of 1/4th of the physical memory or 1GB. Before J2SE 5.0, the default maximum heap size was 64MB. You can override this default using the -Xmx command-line option.

UPDATE:

As pointed out by Tom Anderson in his comment, the above is for server-class machines. From Ergonomics in the 5.0 JavaTM Virtual Machine:

In the J2SE platform version 5.0 a class of machine referred to as a server-class machine has been defined as a machine with

  • 2 or more physical processors
  • 2 or more Gbytes of physical memory

with the exception of 32 bit platforms running a version of the Windows operating system. On all other platforms the default values are the same as the default values for version 1.4.2.

In the J2SE platform version 1.4.2 by default the following selections were made

  • initial heap size of 4 Mbyte
  • maximum heap size of 64 Mbyte
🌐
Eclipse OpenJ9 Blog
blog.openj9.org › 2020 › 04 › 30 › default-java-maximum-heap-size-is-changed-for-java-8
Default Java Maximum Heap Size is changed for Java 8 – Eclipse OpenJ9 Blog
April 30, 2020 - The default values for Xmx is based on the physical memory of the machine. In current OpenJ9 release 0.19: For Java 11 and above The Xmx value is 25% of the available memory with a maximum of 25 GB.
Discussions

Default Xms and Xmx setting for java? - Oracle Forums
Hi, according to the docs for linux (and solaris) (http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/java.html) the default Xms and Xmx settings are 2M and 64MB. I tried this on a virtual server ... More on forums.oracle.com
🌐 forums.oracle.com
January 19, 2006
bash - How do I set the default maximum Java heap size? - Raspberry Pi Stack Exchange
I want to set the default Java heap size to 1024m without needing to specify the -Xmx option every time I run a jar file. Tried adding export JAVA_OPTIONS=-Xmx1024m to .bashrc file but it didn't ... More on raspberrypi.stackexchange.com
🌐 raspberrypi.stackexchange.com
April 25, 2018
What does Java option -Xmx stand for? - Stack Overflow
The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. Examples: ... So, in simple words, you are setting Java heap memory to a maximum of 1024 MB from the available memory, not more. ... It does not matter if you use uppercase or lowercase. For example: "-Xmx10G... More on stackoverflow.com
🌐 stackoverflow.com
memory - What is the default max heap size (-Xmx) in Java 8? - Stack Overflow
In the oracle documentation I found: -Xmxsize Specifies the maximum size (in bytes) of the memory allocation pool in bytes ... The default value is chosen at runtime based on system configuration.... More on stackoverflow.com
🌐 stackoverflow.com
🌐
IBM
ibm.com › docs › en › sdk-java-technology › 8
IBM SDK, Java Technology Edition 8
January 22, 2026 - For example, for a VM with 16 GB RAM, the default maximum size is 25% of RAM, therefore the default value of Xmx will be 4 GB. If the initial size is specified as 6 GB (-Xms6g), then -Xms (6 GB) is greater than -Xmx (4 GB) and before the 0.53.0 ...
🌐
iCert Global
icertglobal.com › blog › what-are-the-default-xmx-and-xms-values
What Are the Default Xmx and Xms Values | iCert Global
August 19, 2025 - To determine the default values of xmx and xms on your machine, you can execute java with the -XX:+PrintFlagsFinal option. This command prints all JVM options and their values, but it generates a lot of output to sift through.
🌐
Azul
docs.azul.com › prime › Heap-Size
Recommended Heap Size
The default value is 1.5625% of the total system memory or cgroup/container limit, and ranges from a minimum 128 MB to a maximum 2 GB. When ZST is installed, this parameter is ignored and the minimum heap size is equal to -Xmx, except when heap elasticity is enabled.
🌐
Oracle
docs.oracle.com › cd › E74363_01 › ohi_vbp_-_installation_guide--20160224-094432-html-chunked › s66.html
2.7.2 JVM Options
The native part of JVM allocation can not be influenced and depends on a number of factors including platform and heap heuristics. ... The perm size should be set to 1024 Megabytes. ... The maximum perm size should be set to 1024 Megabytes. ... Oracle recommends that -Xmn and -Xmx be set to ...
Find elsewhere
🌐
Oracle
docs.oracle.com › cd › E13150_01 › jrockit_jvm › jrockit › jrdocs › refman › optionX.html
-X Command-line Options
Default value depends upon whether you use a dynamic garbage collector (the default garbage collector) or the select a static garbage collector, see Table 2-7 ... You can set -Xns only when using a dynamic garbage collector (-XgcPrio) or a static generational garbage collector (-Xgc:gencon or -Xgc:genpar). The value must be at least four times the size of -XXlargeObjectLimit and it may not be greater than -Xmx.
🌐
Alvin Alexander
alvinalexander.com › blog › post › java › java-xmx-xms-memory-heap-size-control
How to control Java heap size (memory) allocation (xmx, xms) | alvinalexander.com
January 31, 2026 - (The -server flag increases the default size to 32M.) -Xmn size in bytes Sets the initial Java heap size for the Eden generation. The default value is 640K. (The -server flag increases the default size to 2M.) -Xmx size in bytes Sets the maximum size to which the Java heap can grow.
🌐
Broadcom
knowledge.broadcom.com › external › article › 238401 › xms-and-xmx-values-in-jvmoptionstxt-of-p.html
Xms and Xmx values in JVMOptions.txt of Policy Server
August 28, 2025 - The Xms flag has no default value, and Xmx typically has a default value of 256 MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.
🌐
Oracle
forums.oracle.com › ords › apexds › post › default-xms-and-xmx-setting-for-java-1109
Default Xms and Xmx setting for java? - Oracle Forums
January 19, 2006 - Hi, according to the docs for linux (and solaris) (http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/java.html) the default Xms and Xmx settings are 2M and 64MB. I tried this on a virtual server ...
🌐
Heaphero
blog.heaphero.io › home › sizing your heap correctly: understanding -xms and -xmx
-Xmx and -Xms: The Complete Guide to Java Heap Size
May 25, 2026 - The -Xmx flag sets the maximum heap size the hard ceiling on how much memory the JVM can allocate for your application. If your application tries to go beyond it, you get an OutOfMemoryError.
🌐
CodeAhoy
codeahoy.com › 2019 › 09 › 02 › java-xmx-vs-xms
What are -Xms and -Xms parameters in Java/JVM (Updated up to Java 13) | CodeAhoy
September 2, 2019 - $ java -X -Xmixed mixed mode execution (default) -Xint interpreted mode execution only -Xbootclasspath:<directories and zip/jar files separated by :> set search path for bootstrap classes and resources -Xbootclasspath/a:<directories and zip/jar files separated by :> append to end of bootstrap class path -Xbootclasspath/p:<directories and zip/jar files separated by :> prepend in front of bootstrap class path -Xdiag show additional diagnostic messages -Xnoclassgc disable class garbage collection -Xincgc enable incremental garbage collection -Xloggc:<file> log GC status to a file with time stamps
🌐
Baeldung
baeldung.com › home › java › jvm › guide to the most important jvm parameters
Guide to the Most Important JVM Parameters | Baeldung
January 8, 2024 - In this quick tutorial, we’ll explore the most well-known options that we can use to configure the Java Virtual Machine. One of the most common performance-related practices is to initialize the heap memory as per the application requirements. That’s why we should specify minimal and maximal heap size. We can use the below parameters to achieve this: -Xms<heap size>[unit] -Xmx<heap size>[unit] Here, unit denotes the unit in which we’ll initialize the memory (indicated by heap size).
Top answer
1 of 5
378

see here: Java Tool Doc, it says,

-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. Examples:

           -Xmx83886080
           -Xmx81920k
           -Xmx80m

So, in simple words, you are setting Java heap memory to a maximum of 1024 MB from the available memory, not more.

Notice there is NO SPACE between -Xmx and 1024m

It does not matter if you use uppercase or lowercase. For example: "-Xmx10G" and "-Xmx10g" do the exact same thing.

2 of 5
183
C:\java -X

    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by ;>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.
Top answer
1 of 5
175

It varies on implementation and version, but usually it depends on the VM used (e.g. client or server, see -client and -server parameters) and on your system memory.

Often for client the default value is 1/4th of your physical memory or 1GB (whichever is smaller).

Also Java configuration options (command line parameters) can be "outsourced" to environment variables including the -Xmx, which can change the default (meaning specify a new default). Specifically the JAVA_TOOL_OPTIONS environment variable is checked by all Java tools and used if exists (more details here and here).

You can run the following command to see default values:

java -XX:+PrintFlagsFinal -version

It gives you a loooong list, -Xmx is in MaxHeapSize, -Xms is in InitialHeapSize. Filter your output (e.g. |grep on linux) or save it in a file so you can search in it.

2 of 5
51

Like you have mentioned, The default -Xmxsize (Maximum HeapSize) depends on your system configuration.

Java8 client takes Larger of 1/64th of your physical memory for your Xmssize (Minimum HeapSize) and Smaller of 1/4th of your physical memory for your -Xmxsize (Maximum HeapSize).

Which means if you have a physical memory of 8GB RAM, you will have Xmssize as Larger of 8*(1/64) and Smaller of -Xmxsizeas 8*(1/4).

You can Check your default HeapSize with

In Windows:

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

In Linux:

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

These default values can also be overrided to your desired amount.

Top answer
1 of 5
1938

The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool.

This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. For example, starting a JVM like below will start it with 256 MB of memory and will allow the process to use up to 2048 MB of memory:

java -Xms256m -Xmx2048m

The memory flag can also be specified in different sizes, such as kilobytes, megabytes, and so on.

-Xmx1024k
-Xmx512m
-Xmx8g

The Xms flag has no default value, and Xmx typically has a default value of 256 MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.

When using these settings, keep in mind that these settings are for the JVM's heap, and that the JVM can and will use more memory than just the size allocated to the heap. From Oracle's documentation:

Note that the JVM uses more memory than just the heap. For example Java methods, thread stacks and native handles are allocated in memory separate from the heap, as well as JVM internal data structures.

2 of 5
425

Run the command java -X and you will get a list of all -X options:

C:\Users\Admin>java -X
-Xmixed           mixed mode execution (default)
-Xint             interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by ;>
                      set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by ;>
                      append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by ;>
                      prepend in front of bootstrap class path
-Xdiag            show additional diagnostic messages
-Xnoclassgc       disable class garbage collection
-Xincgc           enable incremental garbage collection
-Xloggc:<file>    log GC status to a file with time stamps
-Xbatch           disable background compilation
-Xms<size>        set initial Java heap size.........................
-Xmx<size>        set maximum Java heap size.........................
-Xss<size>        set java thread stack size
-Xprof            output cpu profiling data
-Xfuture          enable strictest checks, anticipating future default
-Xrs              reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni       perform additional checks for JNI functions
-Xshare:off       do not attempt to use shared class data
-Xshare:auto      use shared class data if possible (default)
-Xshare:on        require using shared class data, otherwise fail.
-XshowSettings    show all settings and continue
-XshowSettings:all         show all settings and continue
-XshowSettings:vm          show all vm related settings and continue
-XshowSettings:properties  show all property settings and continue
-XshowSettings:locale      show all locale related settings and continue

The -X options are non-standard and subject to change without notice.

I hope this will help you understand Xms, Xmx as well as many other things that matters the most. :)

🌐
GeeksforGeeks
geeksforgeeks.org › java › how-is-the-default-max-java-heap-size-determined
How is the default max Java Heap size determined? - GeeksforGeeks
July 23, 2025 - Server JVM heap configuration ergonomics are now the same as the Client, except that the default maximum heap size for 32-bit JVMs is 1 gigabyte, corresponding to a physical memory size of 4 gigabytes, and for 64-bit JVMs is 32 gigabytes, ...