Well there are couple of things.

  1. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently
  2. Once the program reaches -Xms heap, jvm request OS for additional memory and eventually grabs -Xmx that requires additional time leading to performance issue, you might as well set it to that at the beginning avoiding jvm to request additional memory.

It is very nicely answered here - https://developer.jboss.org/thread/149559?_sscc=t

Answer from Fairoz on Stack Overflow
🌐
IBM
ibm.com › docs › en › sdk-java-technology › 8
-Xms / -Xmx - IBM Documentation
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 ...
🌐
Reddit
reddit.com › r/admincraft › best values for min-max ram, xms & xmx arguments
r/admincraft on Reddit: Best values for min-max RAM, Xms & Xmx arguments
September 20, 2019 -

Edit: Solved, just set them both to the same value!

---

So when running my server (which has 8GB or RAM) I set my Xms to 2G (minimum RAM) and Xmx to 6GB (maximum RAM). From what I understand this means the server will always use 2GB of RAM but can take up to 6GB if it needs it. It's running on a dedicated Ubuntu server that does nothing but run the MC server, so 2GB for the OS etc. should be fine.

However, I've also read that giving MC too much RAM is bad, and garbage collection will go haywire. I managed to find some good but very cheap RAM so I'll be upgrading to 16GB of RAM this weekend.

My question is, how to determine what to set the min RAM to and what the max RAM? I just picked 2GB as the minimum value at random, as it seemed like a good amount to give the server at minimum. When I put the 16GB in I want to allocate 12GB to my MC server, should I keep the min at 2GB and set the max to 12GB? Could this lead to issues?

My launch parameters (added some line breaks for readability):

java -server -Xms2G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 
-XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 
-XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled 
-Dusing.aikars.flags=mcflags.emc.gs 
-jar $(ls -v | grep -i "FTBServer.*jar\|forge.*jar\|paper-*.*jar\|spigot-*.*jar\|minecraft_server.*jar" | head -n 1) nogui
🌐
iCert Global
icertglobal.com › community › xmx-parameter-and-maximum-jvm-heap-size-explained
What exactly does the -Xmx parameter control in the Java Virtual Machine (JVM), and why is it crucial for application stability?
Kevin, it is often recommended to set -Xms and -Xmx to the same value, especially for server-side or performance-critical applications. When the values are different, the JVM spends extra time resizing the heap as the application demands more memory.
Top answer
1 of 5
28

Well there are couple of things.

  1. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently
  2. Once the program reaches -Xms heap, jvm request OS for additional memory and eventually grabs -Xmx that requires additional time leading to performance issue, you might as well set it to that at the beginning avoiding jvm to request additional memory.

It is very nicely answered here - https://developer.jboss.org/thread/149559?_sscc=t

2 of 5
18

From Oracle Java SE 8 docs:

https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/sizing.html By default, the virtual machine grows or shrinks the heap at each collection to try to keep the proportion of free space to live objects at each collection within a specific range. This target range is set as a percentage by the parameters -XX:MinHeapFreeRatio=<minimum> and -XX:MaxHeapFreeRatio=<maximum>, and the total size is bounded below by -Xms<min> and above by -Xmx<max>. Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. However, the virtual machine is then unable to compensate if you make a poor choice.

if the value of -Xms and -Xmx is same JVM will not have to adjust the heap size and that means less work by JVM and more time to your application. but if the chosen value is a poor choice for -Xms then some of the memory allocated will never be used because the heap will never shrink and if it is a poor choice for -Xmx you will get OutOfMemoryError.

🌐
Oracle
docs.oracle.com › cd › E74363_01 › ohi_vbp_-_installation_guide--20160224-094432-html-chunked › s66.html
2.7.2 JVM Options
Oracle recommends that -Xmn and -Xmx be set to the same value. This eliminates potentially costly heap reallocations, and can reduce the amount of heap fragmentation that can occur.
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. :)

Find elsewhere
🌐
Sentry
sentry.io › sentry answers › java › understanding the java virtual machine's -xms and -xmx parameters
Understanding the Java Virtual Machine's -Xms and -Xmx parameters | Sentry
The -Xms and -Xmx parameters are used to control the initial and maximum heap size allocated to the Java Virtual Machine (JVM). This is the amount of memory in bytes that will be used for creating and storing objects.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › gctuning › factors-affecting-garbage-collection-performance.html
HotSpot Virtual Machine Garbage Collection Tuning Guide
July 15, 2025 - At initialization of the virtual machine, the entire space for the heap is reserved. The size of the space reserved can be specified with the -Xmx option. If the value of the -Xms parameter is smaller than the value of the -Xmx parameter, then not all of the space that's reserved is immediately ...
🌐
Heaphero
blog.heaphero.io › home › sizing your heap correctly: understanding -xms and -xmx
Sizing Your Heap Correctly: Understanding -Xms and -Xmx
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.
🌐
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 - 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. However, where there is 2 GB or less of physical memory, the value set is 50% of available memory with a minimum value ...
🌐
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 - The xmx parameter is employed to specify the amount of memory the JVM can utilize. It defines the limit up to which the JVM can request memory from the operating system for storing objects.
🌐
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.
🌐
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. Checking your Xmx value at runtime is essential for diagnosing memory issues, optimizing ...
🌐
iCert Global
icertglobal.com › what-are-the-default-xmx-and-xms-values- › community
What are the default xmx and xms values ?
Fatal error: Uncaught Error: Undefined constant "REQUEST_URI" in /home2/icertbdh/icertglobal.com/redirect_to_community.php:3 Stack trace: #0 {main} thrown in /home2/icertbdh/icertglobal.com/redirect_to_community.php on line 3
🌐
Veritas
veritas.com › support › en_US › doc › 140726114-166019498-0 › v168372758-166019498
Override default Java Heap memory (XMX) value for Data Collector utilities | Data Collector Troubleshooting | NetBackup IT Analytics Data Collector Notes and Troubleshooting | Veritas™
August 1, 2025 - To override the default XMX value for Data collector Linux batch scripts, uncomment the XMX variable in dc_override_config.sh present in the mbs/conf directory and provide the updated XMX value.