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
🌐
Baeldung
baeldung.com › home › java › jvm › guide to the most important jvm parameters
Guide to the Most Important JVM Parameters | Baeldung
January 8, 2024 - 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.
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.

Discussions

java - What are the -Xms and -Xmx parameters when starting JVM? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... when using -Xmx128m -Xms64m it can peak around 275m RES mem, but when using -Xmx128m -Xms128m it can peak around 550m RES mem Using Java 8 Best thing is to stress the GC and look at what happens ... More on stackoverflow.com
🌐 stackoverflow.com
Best values for min-max RAM, Xms & Xmx arguments
Make your Xms ans Xmx the same value, so both 6GB. Unused RAM is bad RAM More on reddit.com
🌐 r/admincraft
12
15
September 20, 2019
performance - Speed tradeoff of Java's -Xms and -Xmx options - Stack Overflow
Given these two commands A: $ java -Xms10G -Xmx10G myjavacode input.txt B: $ java -Xms5G -Xmx5G myjavacode input.txt I have two questions: Since command A reserves more memory with its parameters, More on stackoverflow.com
🌐 stackoverflow.com
Java process consuming more memory than assigned Max heap
Java using more memory than Xmx is totally normal. You can at least calculate 1MB for each thread and 1MB for each TCP connection. If you run Java in Containers, we usually calculate Xmx * 1.5 for the container. This is a good video explaining it: https://www.youtube.com/watch?v=uJLOlCuOR4k If you have the impression of java processes eating even more than that, look into reusing TCP connections with pools, not leaking connections, etc. More on reddit.com
🌐 r/devops
15
12
February 28, 2024
🌐
CloudBees
docs.cloudbees.com › knowledge base › java heap settings best practice
Java Heap settings Best Practice
If -Xmx is passed, the JVM will ignore -XX:MaxRAMPercentage (respectively, if -Xms is passed, the JVM will ignore -XX:InitialRAMPercentage). c. Do not use a ratio JVM heap / Container Memory limit higher than 0.5. It is known to be unstable and may cause unexpected controller restarts due to ...
🌐
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 - -Xms size in bytes Sets the initial size of the Java heap. The default size is 2097152 (2MB). The values must be a multiple of, and greater than, 1024 bytes (1KB). (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 ...
🌐
Medium
medium.com › @ansujain › understanding-jvm-settings-xmx-xss-and-java-thread-states-in-applications-017f11c1e2b0
Understanding JVM Settings: -Xmx, -Xss, and Java Thread States in Applications | by ansu jain | Medium
November 25, 2023 - Balancing Act:Select an appropriate -Xmx value by finding a balance between avoiding frequent garbage collection (with a too-small heap) and preventing excessive memory consumption (with a too-large heap).
🌐
Informatica Knowledge
knowledge.informatica.com › s › article › 497225
FAQ: What are the guidelines and best practices to increase Java heap size and other memory attributes of the Informatica Cloud Secure Agent?
April 9, 2025 - If you have already used all the available JVMOptions, then you can add more as custom properties on the agent, making sure the sequence is maintained (if the default ones stop at JVMOption5, then the custom properties should start with JVMOption6 and should have type as DTM and subtype as INFO). Each JVMOption can take 1 JVM property. The main JAVA memory properties are -Xms**m , -Xmx****m.
Find elsewhere
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. :)

🌐
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 › blog › what-are-the-default-xmx-and-xms-values
What Are the Default Xmx and Xms Values | iCert Global
August 19, 2025 - To execute an application with ... gigabytes is standard usage. Choosing values suitable for your application's memory needs and taking into account other processes that will run on your system is a good practice....
🌐
GC easy
blog.gceasy.io › home › benefits of setting initial and maximum memory size to the same value
Boost Java Performance: Set Initial & Max Memory to Same Value
March 30, 2026 - For optimal startup performance, set the initial heap size to be the same as the maximum heap size.” · Irrespective of whether you set your initial heap size (-Xms) and maximum heap size (-Xmx) to the same value or different value, the computing ...
🌐
Medium
medium.com › @marketing_864 › best-practices-java-memory-arguments-for-containers-1d704a65f7db
Best practices: Java memory arguments for Containers | by Ram Lakshmanan | Medium
December 17, 2020 - Best practices: Java memory arguments for Containers When you are running your Java application in physical servers, you would have been using ‘-Xmx’ JVM argument to specify the Java heap size …
🌐
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 - It’s important to note that your Java process will always consume more RAM than the value you set for -Xmx. This is because -Xmx only controls the heap. The JVM also uses additional memory regions, including the thread stack, Metaspace (for class metadata), code cache, and native/direct memory buffers, none of which count against the heap limit. So if you set -Xmx to 2 GB, your OS-level RAM utilization will typically be 30–50% higher. The -Xmx and -Xms parameters do not directly correspond to total RAM utilization; they only govern the heap portion of a much larger memory footprint.
🌐
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 - The options -XX:NewSize and -XX:MaxNewSize bound the young generation size from below and above. Setting these to the same value fixes the young generation, just as setting -Xms and -Xmx to the same value fixes the total heap size.
🌐
Javagyansite
javagyansite.com › 2023 › 08 › 06 › xms-and-xmx-parameters
Xms and Xmx Parameters in Java:Optimize Memory Allocation - Javagyansite
August 6, 2023 - This can help to reduce the overhead of dynamic heap resizing during the initial execution phase. ... You can use the Xmx parameter to specify the maximum heap size that the Java Virtual Machine (JVM) can allocate for your application.
🌐
Codemia
codemia.io › home › knowledge hub › what are the -xms and -xmx parameters when starting jvm?
What are the -Xms and -Xmx parameters when starting JVM? | Codemia
December 28, 2024 - Stability and Predictability: Providing ... grows and stabilizes earlier. Match -Xms and -Xmx: Setting -Xms and -Xmx to the same value can increase predictability by removing the need for the JVM to resize its heap....
🌐
Chroniclejournal
markets.chroniclejournal.com › chroniclejournal › article › prlog-2026-3-5-heaphero-shares-java-heap-sizing-best-practices-choosing-the-right-xms-and-xmx-parameters
User | chroniclejournal.com - HeapHero Shares Java Heap Sizing Best Practices: Choosing the Right -Xms and -Xmx Parameters
March 5, 2026 - The Heap Sizing Trap Most developers rely on JVM defaults for -Xms and -Xmx, but improper sizing is costly. A heap that is too small triggers constant GC, CPU spikes, and crashes. Conversely, a heap that is too large wastes OS memory, inflates cloud bills, and leads to agonizingly long GC pauses. "​Worse, -Xmx only tweaks the Java heap, not metaspace, threads, or native memory, where most OutOfMemoryErrors hide.
🌐
Quora
quora.com › Why-is-it-recommended-to-have-Xms-and-Xmx-memory-jvm-arg-values-be-same-in-middleware-application-server
Why is it recommended to have Xms and Xmx(memory jvm arg) values be same in middleware application server? - Quora
Once you understand the principles ... to you: Java VM Options You Should Always Use in Production. Read the discussion below the article as well. It’s partly about if and when to use Xms=Xmx. At the end of the day - your hardware, your application, your responsibility and your decisions. You have to figure out what is the best in your ...