Aikar's flags and JVM flags for Minecraft

By Kosy · · 2 min read

If you have searched for "Minecraft server startup flags", you have met Aikar's flags. They are a list of Java options that make the game's memory cleaner run in short, frequent bursts instead of rare long ones. Long pauses are felt as lag spikes, so shorter ones feel smoother.

What the flags do

Minecraft allocates and throws away a huge number of small objects every tick. Java cleans them up with a garbage collector. The default settings are made for general programs. A game wants short pauses, because a tick that takes 400 milliseconds is a visible stutter.

Aikar's flags tune the G1 collector so that:

  • the young generation, where new objects live, is large, so most objects die there cheaply
  • pauses aim at 200 ms or less (-XX:MaxGCPauseMillis=200)
  • the collector starts working earlier, before memory is nearly full

The best known options are -XX:+UseG1GC, -XX:G1NewSizePercent=30, -XX:G1MaxNewSizePercent=40, -XX:G1HeapRegionSize=8M and -XX:InitiatingHeapOccupancyPercent=15. You never need to type them by hand: the JVM flags generator builds the whole line for your memory.

The memory flags matter more

Two flags decide how much memory the game may use: -Xms (the start size) and -Xmx (the maximum). Set them to the same value so Java does not resize while you play. Leave room for everything that is not the heap. The operating system, Java's own structures, and the map renderer all need memory outside the heap. A good rule is to give the heap about 75 percent of the memory you have, not all of it.

When Aikar's flags help and when they do not

They help most on servers with 4 GB or more and 15 or more players, where garbage collection is a real share of the work. On a small server with 1 or 2 GB, the default settings are fine, and some flags (like a large region size) can even waste memory. If your lag comes from too many entities or a heavy plugin, no flags will fix it: see how to fix Minecraft server lag and profile first.

Newer Java, newer advice

Aikar's list was written for Java 8 to 17. Newer Java versions have better defaults, and Minecraft 1.20.5 and later need Java 21, with 26 and later needing Java 25. Check which one you need with the Java version checker. On a modern Java, many people use the same flags or a shorter list, and it matters less than it used to.

On Saryno

You do not set flags by hand. The Performance tab of a server has a Java flags section with a few presets: a balanced default, Aikar's flags, a low-memory choice for 1 GB or less, and one for many players. The change applies the next time the game starts. Before you change it, press Run a profile and look at the report, so you can tell afterwards whether it helped.

Checklist

  1. Give the heap about 75 percent of your memory.
  2. Set -Xms and -Xmx the same.
  3. Use the generator for the rest.
  4. Measure before and after with a profile.

More to read