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.

Answer from Nishant on Stack Overflow
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.
🌐
Oracle
docs.oracle.com › cd › E13150_01 › jrockit_jvm › jrockit › jrdocs › refman › optionX.html
-X Command-line Options
Depending upon the kind of operating ... as 64 bytes, not 64 megabytes or 64 kilobytes. The -Xmx option and -Xms option in combination are used to limit the Java heap size....
🌐
IBM
ibm.com › docs › en › sdk-java-technology › 8
IBM SDK, Java Technology Edition 8
January 22, 2026 - The Oracle® HotSpot™ option -Xms sets the initial or the minimum Java™ heap size, and the -Xmx HotSpot option sets the maximum heap size.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › jvm-options-java-parameters-command-line-environment-variable-list-xms-xmx-memory
Critical Java JVM options and parameters
To use any of these JVM options, simply append them as text after the java runtime command. For example, the following command runs an app called Go with six different parameter sizes to optimize for memory allocation and garbage collection: java Go -XX:MaxPermSize=128m -XX:MaxNewSize=256m -Xms768m -Xmx768m -XX:SurvivorRatio=128 -XX:MaxTenuringThreshold=0
🌐
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.
Find elsewhere
🌐
Squash
squash.io › how-to-use-java-option-xmx
How to Use the Xmx Option in Java - Squash Labs
November 3, 2023 - The Xmx option is part of the Java HotSpot VM options and is used to set the maximum heap size. It takes a numeric value followed by a unit of memory.
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. :)

🌐
Index.dev
index.dev › blog › check-xmx-value-java-runtime
Java Xmx: Check Max Heap Size at Runtime | -Xmx Command & Examples | Index.dev
February 14, 2025 - The -Xmx JVM option sets the maximum heap size for your Java application. It controls how much memory the JVM can allocate before throwing an OutOfMemoryError.
🌐
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).
🌐
Eclipse Foundation
eclipse.dev › openj9 › docs › xms
-Xms / -Xmx -
The Oracle® HotSpot™ option -Xms sets the initial or the minimum Java™ heap size, and the -Xmx HotSpot option sets the maximum heap size.
🌐
Codemia
codemia.io › knowledge-hub › path › what_does_java_option_-xmx_stand_for
What does Java option -Xmx stand for?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
Elastic
elastic.co › elastic docs › reference › elasticsearch › jvm settings
JVM settings | Elasticsearch Reference
To configure the heap size, add the Xms and Xmx JVM arguments to a custom JVM options file with the extension .options and store it in the jvm.options.d/ directory. For example, to set the maximum heap size to 2GB, set both Xms and Xmx to 2g: ... The ES_JAVA_OPTS variable overrides all other JVM options.
🌐
JRebel
jrebel.com › system › files › 2025-06 › cheat-sheet-rebel-jvm-options.pdf pdf
www.jrebel.com JVM Options Cheat Sheet STANDARD OPTIONS NON-STANDARD OPTIONS
$ java -X · List all non-standard options. -Xint · Runs the application in interpreted-only mode. -Xbootclasspath:path · Path and archive list of boot class files. -Xloggc:filename · Log verbose GC events to filename. -Xms1g · Set the initial size (in bytes) of the heap. -Xmx8g ·
🌐
JetBrains
jetbrains.com › help › idea › increasing-memory-heap.html
Increase the memory heap of the IDE | IntelliJ IDEA Documentation
March 17, 2026 - If you are using a standalone instance not managed by the Toolbox App, and you cannot start it, it is possible to manually change the -Xmx option that controls the amount of allocated memory. Create a copy of the default JVM options file and change the value of the -Xmx option in it. 17 March 2026 · Change the boot Java runtime of the IDEMonitor IDE performance
🌐
Oracle
docs.oracle.com › cd › E74363_01 › ohi_vbp_-_installation_guide--20160224-094432-html-chunked › s66.html
2.7.2 JVM Options
Java will allocate a certain amount of memory for the native part of the JVM, as well as a per thread call stack and reserved code cache for JIT compilation. 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 the same value.