Guides / Startup flags

Aikar's flags explained

What each of Aikar's JVM flags does for a Minecraft server, and when to use the large-heap variant.

Updated

Aikar's flags are a set of Java settings tuned for Minecraft servers. PaperMC recommends them for every server, and they work with vanilla, Paper, Fabric and Forge.

Generate a ready-to-use set with your memory filled in using the startup flags generator.

The problem they solve

Minecraft creates huge numbers of short-lived objects every tick. Java's default settings are made for general programs, so cleaning those up can freeze the server for a moment. Players feel it as lag spikes. Aikar's flags tune the garbage collector to clean up often, in short pauses.

What the groups do

Memory

-Xms and -Xmx set the same, so Java reserves all its memory at startup. See Xms and Xmx explained.

The G1 collector

-XX:+UseG1GC picks the G1 garbage collector, and -XX:MaxGCPauseMillis=200 tells it to keep pauses short.

G1 sizing

G1NewSizePercent, G1MaxNewSizePercent, G1HeapRegionSize and the others give more room to new objects, which is where Minecraft's garbage lives.

Housekeeping

  • -XX:+DisableExplicitGC stops plugins forcing a full cleanup
  • -XX:+AlwaysPreTouch reserves the memory at startup instead of during play
  • -XX:+PerfDisableSharedMem stops Java writing stats to disk, which can stall slow disks

The large-heap variant

Above 12 GB, Aikar recommends bigger regions and more room for new objects: G1NewSizePercent=40, G1MaxNewSizePercent=50, G1HeapRegionSize=16M, G1ReservePercent=15 and InitiatingHeapOccupancyPercent=20. The generator switches automatically.

Do they still matter on new Java?

Yes. Newer Java versions have better defaults, but these flags are still tuned more closely to how Minecraft uses memory.

Work it out for your server

The free Startup flags generator gives you the exact settings for your setup.

Open the Startup flags generator →