Guides / Startup flags
Xms and Xmx explained for Minecraft servers
What -Xms and -Xmx mean, why they should match on a server, and how much to set them to.
Updated
-Xmx sets the most memory Java can use for the server. -Xms sets how much it starts with. For a dedicated Minecraft server, set them to the same value.
java -Xms6G -Xmx6G -jar paper.jar nogui
Why set them the same
If -Xms is lower, Java starts small and grows the heap as the server needs it. Growing and shrinking takes time, and the memory may not be there when Java asks for it. Setting both the same means the server reserves its memory once, at startup.
How much to set
Use the RAM your server actually needs, not everything the machine has.
- Your own PC or VPS: leave 1–2 GB for the operating system. On an 8 GB machine, use 6 GB.
- A panel like Pterodactyl: the panel sets the container's limit, and Java needs some memory outside the heap. The startup flags generator uses
-XX:MaxRAMPercentage=90.0so the heap fits.
Not sure how much you need? Use the RAM calculator.
M or G?
Both work. -Xmx6G and -Xmx6144M are the same. Don't add a space or a "B": -Xmx6GB is an error.
Common mistakes
- Setting `-Xmx` higher than the machine's RAM. The system starts swapping to disk and everything slows down.
- Putting the flags after `-jar`. Java options must come before
-jar, or they're passed to Minecraft and ignored. - Forgetting flags on Forge. On Forge and NeoForge 1.17 and newer, they go in
user_jvm_args.txt.