
If your server stutters every few seconds even when the TPS looks fine, garbage collection is a likely suspect. Java pauses the server to clean up memory, and with the default settings those pauses can be long enough for players to feel.
Aikar's flags are a set of Java startup options, tuned by a long-time Paper contributor, that make those pauses shorter and more predictable. PaperMC recommends them, and they're the standard starting point for almost every Paper server.
The startup line
For a server with up to 12 GB of memory, replace 10G with your amount in both places:
java -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 paper.jar --nogui
If you give the server more than 12 GB, change these five values:
| Flag | Up to 12 GB | Over 12 GB |
|---|---|---|
G1NewSizePercent |
30 | 40 |
G1MaxNewSizePercent |
40 | 50 |
G1HeapRegionSize |
8M | 16M |
G1ReservePercent |
20 | 15 |
InitiatingHeapOccupancyPercent |
15 | 20 |
Paper's own documentation keeps the current version of these flags, and also offers a startup script generator if you'd rather not write it by hand.
What the important parts do
-Xmsand-Xmxset to the same value. The server claims all its memory at startup instead of growing and shrinking, which avoids extra work later. Together withAlwaysPreTouch, the memory is ready from the first tick.UseG1GCwithMaxGCPauseMillis=200. G1 is the garbage collector these flags are built around, with a target for how long each pause may take.- The
G1NewSizevalues. Minecraft creates a huge number of short-lived objects every tick. Giving the young generation more room means most of that garbage is cleared quickly and cheaply. DisableExplicitGC. Stops plugins from forcing a full garbage collection, which can freeze the server.
How much RAM to give it
More isn't automatically better. A server with far more memory than it needs collects garbage less often, but each collection has more to clean. For most servers:
- A small survival server: 6 to 10 GB.
- A busy survival or skyblock server: 10 to 16 GB.
Always leave memory for the operating system, and for anything else running on the machine. If your host's panel shows a total, give the server a little less than all of it.
Mistakes that make it worse
- Mixing flag sets. Copying lines from several guides into one startup command often gives the JVM conflicting instructions. Use one set.
- Setting
-Xmxto everything the machine has. The OS starts swapping, and swapping is far slower than any GC pause. - Treating flags as a fix for lag. Flags smooth out garbage collection. They don't make an overloaded server fast. If the tick itself is too slow, find out what's taking the time.
When the flags aren't the problem
If the server is still lagging, profile it. Our guide to finding lag with spark walks through it. On survival and skyblock servers, the result is very often entities: mob farms and spawners creating thousands of mobs and dropped items.
That's the problem EliteSpawner was built to remove. Its spawners are fully virtual: vanilla spawning is cancelled before a mob exists, and drops go straight into storage, so a room full of spawners creates no entities at all. It runs on Paper, Purpur and Folia, and buying direct from the DenizenMC store is 10% cheaper than the marketplaces.
Get the tools from this guide
Built and tested on real servers, with updates included and support on Discord.
