Minecraft and JVM Arguments
So I’ve been running a Minecraft server for me and my brothers to play on. But me being an optimisation freak, I wanted to see how far I could stretch that 2GB server I rented for $3. After running PaperMC and following this amazing guide I still wanted more. All that was left, however, was the JVM arguments.
Now after a little accident as a kid where I corrupted my world by messing with them (or so I thought), I was still quite weary. But given some a lot of time of reading through Java documentation, they weren’t as scary as I previously thought. With that effort, I think I can safely say I’ve found quite the optimial JVM arguments for both a Minecraft server and client. A special thanks is due for Daniel Ennis (Aikar); his documentation was a great insight - along with being the base for the server configuration below.
Servers (Java 8 - 11)#
-Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
Replace server.jar
with the Minecraft server JAR you are using.
Fabric servers are currently not supported [by this guide].
Clients (Java 8 - 11):#
-Xms6G -Xmx6G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=50 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=20 -XX:G1HeapRegionSize=32M -XX:G1ReservePercent=20 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1
Fabric Clients (Java 14):#
-Xms6G -Xmx6G -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1
Experimental Changes#
For Linux systems (Java 8 - 11):#
Enable THP (Transparent Huge Pages) in your bootloader, and then add -XX:+UseTransparentHugePages
to the JVM arguments.
For NUMA systems (Java 8 - 11):#
Add -XX:+UseNUMA
to the JVM arguments.
For Windows systems (Java 8 - 11):#
Run as a user with the “Lock Pages in Memory” privilege, and add -XX:+UseLargePagesInMetaspace
to the JVM arguments.