NewWelcome to our new site

Minecraft

How to Optimize Minecraft Server Performance with Aikar's Flags

Guide to implementing Aikar's flags for Minecraft server optimization.

Aikar's Flags are JVM startup parameters that improve server performance by optimizing garbage collection and memory management. They reduce lag spikes and provide smoother gameplay.

All Altare Minecraft servers come with Aikar's flags by default.

Note

Aikar's Flags allocates all available memory, so your server may appear to use 100% RAM. This is normal. Install the Spark plugin and run /spark health to see actual usage.

Setting Up the Flags

Update your server startup command with the flags below. Replace {SERVER_MEMORY} with your RAM amount (e.g., 4096 for 4GB).

Less than 12GB of RAM

java -Xms{SERVER_MEMORY}M -Xmx{SERVER_MEMORY}M -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

12GB of RAM or more

java -Xms{SERVER_MEMORY}M -Xmx{SERVER_MEMORY}M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=20 -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

Flag Breakdown

Note

On shared hosting (like Altare), leave about 1GB for JVM overhead. This is done automatically.

Key flags:

  • -Xmx / -Xms: Maximum and initial memory (set to same value)
  • -XX:+UseG1GC: Enables G1 garbage collector for better performance
  • -XX:+ParallelRefProcEnabled: Parallel reference processing
  • -XX:MaxGCPauseMillis: Maximum garbage collection pause time
  • -XX:+DisableExplicitGC: Prevents bad plugin code from affecting GC

Warning

Remove -XX:+AlwaysPreTouch on Pterodactyl/containerized servers. It can cause crashes by pre-allocating all memory.

Other flags fine-tune G1 garbage collection settings. See Aikar's blog for detailed explanations.

If you have issues, check server.log for error messages.

Common Issues

Server shows 100% RAM usage

  • Normal behavior - flags allocate all available memory
  • Fix: Use Spark plugin and run /spark health for actual usage

Server crashes with "Cannot allocate memory"

  • Usually caused by -XX:+AlwaysPreTouch in containers
  • Fix: Remove -XX:+AlwaysPreTouch flag

Poor performance

  • Incorrect memory allocation or wrong Java version
  • Fix: Use Java 11+ and leave 1GB for JVM overhead
How to Optimize Minecraft Server Performance with Aikar's Flags