Aikar's flags: JVM and RAM settings explained
Updated September 2026 · More RAM is not always faster. The right flags and the right heap size matter more than the number on the plan.
What the flags are for
A Minecraft Java server runs inside the Java Virtual Machine (JVM). Every few seconds the JVM runs garbage collection (GC): it clears out memory the server no longer needs. A badly tuned GC pauses the whole server for a moment — you feel it as regular lag spikes, even when TPS looks fine on average.
Aikar’s flags are a set of JVM startup options, written by Aikar, a long-time Paper contributor, that tune the G1 garbage collector for how Minecraft uses memory: lots of short-lived objects, created every tick. They are the standard recommendation in the Paper documentation and work for vanilla, Fabric and Forge too.
The flags
For servers with up to 12 GB of heap:
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
For more than 12 GB, change these five values:
| Flag | Up to 12 GB | Above 12 GB |
|---|---|---|
G1NewSizePercent |
30 | 40 |
G1MaxNewSizePercent |
40 | 50 |
G1HeapRegionSize |
8M | 16M |
G1ReservePercent |
20 | 15 |
InitiatingHeapOccupancyPercent |
15 | 20 |
Replace server.jar with your server file and 10G with your heap size.
Xms and Xmx: set them equal
-Xmxis the maximum heap the server may use.-Xmsis the heap it starts with.
Aikar’s recommendation is to set both to the same value. The server then claims its memory once at startup instead of growing and shrinking, and AlwaysPreTouch makes sure that memory is really there.
How much heap to give
This is where most people go wrong.
Do not give the JVM all the memory the machine or plan has. Java needs memory outside the heap too: for threads, loaded classes, native libraries and the network. If the heap is as large as the total memory, the operating system or container kills the process when that extra memory is needed. You see a sudden crash without a Java error.
Leave some headroom. How much depends on the server and its plugins or mods; about a gigabyte is a common starting point on a home machine. Many hosts set this for you automatically; if you edit startup flags yourself, check how the host calculates the heap first.
More is not always better. A vanilla server with five friends gains nothing from 16 GB. A larger heap just means garbage collection has more to clean each time. Give what the server actually needs — how much RAM a Minecraft server needs has the numbers.
Signs your RAM or flags are wrong
| Symptom | Likely cause |
|---|---|
| Lag spikes every few seconds or minutes, TPS otherwise fine | GC pauses; no or old flags |
| “OutOfMemoryError” in the log | Heap too small for the world or modpack |
| Server dies without an error message | Heap too close to total memory |
| Memory usage always near 100 % in the panel | Normal with Xms = Xmx and AlwaysPreTouch — not a problem |
That last one confuses a lot of people. With these flags the JVM reserves the full heap at startup, so memory usage looks full from the first minute. What matters is how the server performs, not the memory graph.
Check GC with spark
Install the spark plugin or mod and run /spark health or a profiler session. It shows garbage collection times and frequency. Short, regular collections are healthy. Long pauses of several hundred milliseconds point to a heap that is too small, too large or untuned.
Java version
Use the Java version your Minecraft version needs; Minecraft 1.20.5 and newer need at least Java 21. Newer Java versions also ship newer garbage collectors. Aikar’s G1 flags remain the safe default; only switch to something else if you know why and can measure the difference.
When flags will not help
Flags smooth out memory pauses. They do not fix too many entities, huge redstone clocks or chunk generation. If spark shows the time going into ticking the world rather than GC, go to fix lag: TPS and MSPT explained. And if you are still choosing your setup, how to make a Minecraft server covers the basics first.