Aikar's Flags: Java Startup Options for a Smoother Minecraft Server
Aikar's flags are a set of Java options tuned for the G1 garbage collector. They are widely used on Paper servers to reduce lag spikes caused by garbage collection. They help most on plugin servers with a moderate amount of RAM.
The flags
These are the commonly published flags for heaps under about 12 GB. Replace 6G with your memory:
java -Xms6G -Xmx6G -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
For very large heaps, the author publishes different values, so check the official page before copying.
Memory tips
- Set -Xms and -Xmx to the same value.
- On a panel, leave some memory free beyond the heap for Java itself. Setting the heap equal to the full container limit can cause the server to be killed. A heap around 80 to 90 percent of the limit is a common rule of thumb.
- More memory is not always better, because a very large heap can cause longer pauses.
Apply them on a panel
- Check the Startup tab of your server. Some servers have a field for extra Java flags, and others have a full startup command.
- Paste the flags, keeping the memory value linked to the panel variable if there is one.
- Make sure the jar name matches your server file.
- Restart and read the console for errors.
Ask us on Discord if you cannot find the setting.
Limits
Flags do not fix everything. Heavy plugins, too many loaded chunks and high view distance are more common causes of lag. Lower view-distance and simulation-distance first, then try flags.
Troubleshooting
- Unrecognized VM option: a flag is not supported by your Java version, so remove it.
- Server will not start: memory value is higher than the plan limit.