Minecraft JVM Flags Generator
Build a start script with Aikar's flags or the tuned set we run in production, with every flag explained and the memory maths shown.
4 GB
Flags
The set MCHosts runs in production, tuned from the Bruce the Moose benchmarks and adjusted for how much memory the server has.
Your startup script
@ECHO OFF REM Generated by MCHosts REM https://mchosts.com.au/tools/minecraft-jvm-flags-generator java -Xms4096M -Xmx4096M -Djava.net.preferIPv4Stack=true -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+AlwaysActAsServerClassMachine -XX:+DisableExplicitGC -XX:+UseNUMA -XX:NmethodSweepActivity=1 -XX:-DontCompileHugeMethods -XX:MaxNodeLimit=240000 -XX:NodeLimitFudgeFactor=8000 -XX:+UseVectorCmov -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:ThreadPriorityPolicy=1 -XX:AllocatePrefetchStyle=3 -XX:ReservedCodeCacheSize=400M -XX:+UseG1GC -XX:MaxGCPauseMillis=130 -XX:G1NewSizePercent=28 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=20 -XX:G1MixedGCCountTarget=3 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=0 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:G1SATBBufferEnqueueingThresholdPercent=30 -XX:G1ConcMarkStepDurationMillis=5 -jar paper.jar --nogui REM Keeps the window open after the server stops so you can read any errors. pause
29 tuning flags, heap 4 GB
On MCHosts you never need this. Flags are applied automatically and tuned to your plan, which is what the numbers above are showing.
Flags only help if the hardware is there
Tuning the garbage collector cannot create memory you do not have. MCHosts plans come with dedicated RAM and Australian hardware, so the flags are working with something.
🔒 Risk-free, 7 day money back guarantee. Australian servers, set up in minutes.
Why -Xms and -Xmx should match
Java starts with a small heap and grows it as the server needs more. That sounds sensible and is the wrong behaviour here, because growing the heap is itself a pause, and it happens when the server is already busy enough to need more memory. In other words, at the worst possible moment.
Setting the two equal means the heap is claimed once at startup and never has to grow again. The server takes a moment longer to come up and then runs without that particular interruption.
The one argument against it is that the process holds the memory whether or not it is using it, which only matters if you are running other things on the same machine. On a dedicated server, or a hosted one, there is nothing else to hold it for.
What these flags actually fix
It is worth being clear about what tuning can and cannot do, since the promises made for flags are often oversold.
They will not raise your ticks per second on a server that is genuinely overloaded, and they will not make up for too little memory, too many entities or a badly behaved plugin. If the server is doing more work than it can finish in a tick, no garbage collector setting changes that.
What they do fix is pauses. Java stops the server periodically to tidy up memory, and Minecraft creates a very large number of short-lived objects, so that happens often. Untuned, those pauses run into hundreds of milliseconds and players feel them as a regular stutter. Tuned, they are short enough to disappear inside a tick and nobody notices them at all.
Why our flags differ from Aikar's
Aikar's flags are a good default and there is nothing wrong with using them. They are also nearly a decade old now, written for one heap size, and every hosting company's generator hands you the same copy of them.
The set we run is based on the Bruce the Moose benchmarks instead, and differs in two ways that matter. It changes with the size of the server, so a 2 GB server and a 16 GB server get different collector settings and different amounts of room for compiled code. And it starts collecting earlier, at 10% of the heap rather than 15%, on the principle that collecting little and often beats waiting until the heap is nearly full and then stopping the world.
Switch between the two in the tool above and the flag list updates, with an explanation against every line, so you can compare them rather than take either on faith.
Frequently asked questions
On MCHosts all of this is applied for you and tuned to your plan. Browse our server plans, size one up with the RAM calculator, or set the rest of your server up with the server.properties generator.