What are Aikars Flags?
Aikars JVM flags are a widely-tested set of Java garbage collection parameters specifically optimized for Minecraft servers. They minimize GC pauses, reduce lag spikes, and improve overall server performance. These flags are recommended by Paper, Purpur, and most Minecraft hosting providers.
The Flags
# For servers with 12GB+ available
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 server.jar nogui
Understanding Key Parameters
- -Xms and -Xmx: Set both to the same value to prevent heap resizing during gameplay
- UseG1GC: G1 garbage collector, best for Minecraft workloads
- MaxGCPauseMillis=200: Target max GC pause of 200ms
- G1NewSizePercent=30/40: Allocates more space for short-lived objects (common in MC)
- G1HeapRegionSize=8M: Optimal region size for MC memory patterns
- AlwaysPreTouch: Pre-allocates memory pages at startup for consistent performance
Flags for Different RAM Amounts
# 4GB server (small vanilla/Paper)
-Xms3G -Xmx3G [same flags above]
# 8GB server (modded or medium)
-Xms6G -Xmx6G [same flags above, but G1HeapRegionSize=16M above 12GB]
# 16GB+ server (large modpacks)
-Xms12G -Xmx12G -XX:G1HeapRegionSize=16M [rest same]
Additional Optimizations
# server.properties optimizations
view-distance=8
simulation-distance=6
network-compression-threshold=256
# For Paper servers, optimize paper-global.yml:
# chunk-loading: autoconfig-send-distance, max-concurrent-sends
# Use Spark plugin to monitor TPS and GC activity
Monitoring GC Performance
# Add GC logging to your flags
-Xlog:gc*:file=/opt/minecraft/logs/gc.log:time,uptime:filecount=5,filesize=10M
# Use Spark plugin in-game:
/spark gc # View GC statistics
/spark tps # Monitor TPS
/spark profiler # CPU profiling
Common Mistakes
- Setting -Xms lower than -Xmx causes heap resizing and lag spikes
- Allocating too much RAM can cause longer GC pauses
- Using ZGC or Shenandoah instead of G1GC (not optimal for MC)
- Running on a version of Java that is too old (use Java 17+ for MC 1.17+)