In short
Aikar's flags are JVM startup parameters for Minecraft servers that tune Java's G1 garbage collector to run with short, frequent pauses. Xms and Xmx are set to the same value, 1-2 GB below your plan's RAM. For heaps larger than 12 GB, some G1 values are raised. The parameters go in the startup line before -jar.
In this guide
- Why does the garbage collector (GC) matter?
- Who are Aikar's flags for?
- Aikar's flags: the full startup line
- What do the parameters do?
- Setting Xms and Xmx based on your plan's RAM
- Adding the flags to the startup line in your panel
- Which Java version should you use?
- Measuring the effect of the change
- Common situations
- Next step: Pick enough RAM for your flags
Aikar's flags are Java (JVM) startup parameters created by Aikar in the Minecraft server community and recommended by the Paper project. Their goal is to reduce periodic server freezes by tuning Java's G1GC garbage collector to the way Minecraft uses memory. Using them correctly comes down to two rules: set -Xms and -Xmx to the same value, and keep that value a bit below your plan's total RAM. Below we explain what the parameters do, how to choose your RAM value, and how to add them to your startup line.
Why does the garbage collector (GC) matter?
A Minecraft server creates huge numbers of short-lived objects every second: chunk data, packets, entity calculations. Java cleans these objects up with the garbage collector (GC). While GC runs, the application can pause briefly. If those pauses get long, players feel them as freezes lasting a few seconds, blocks snapping back, or TPS drops.
G1GC (Garbage-First) is a pause-time-focused garbage collector that splits memory into small regions and cleans the regions with the most garbage first. Aikar's flags tune G1GC for Minecraft's “lots of short-lived objects” profile.
Who are Aikar's flags for?
You can use these parameters on Vanilla, Paper, Purpur, Spigot, Forge, NeoForge, and Fabric servers alike, because they're passed directly to Java, not to Minecraft. You'll see the biggest benefit when:
- The server has short, server-wide freezes that repeat every few minutes.
- Memory usage draws a jagged graph as player count grows.
- You run a modpack or a server with lots of plugins.
Not all lag comes from GC, but the right JVM settings are a solid foundation for every other optimization, and applying them takes only a few minutes.
Aikar's flags: the full startup line
The standard line for heaps of 12 GB or less (10 GB example):
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
If your heap is larger than 12 GB, change these five values:
-XX:G1NewSizePercent=40
-XX:G1MaxNewSizePercent=50
-XX:G1HeapRegionSize=16M
-XX:G1ReservePercent=15
-XX:InitiatingHeapOccupancyPercent=20
You can find the current official line and its explanation in the PaperMC documentation.
What do the parameters do?
| Parameter | What it does |
|---|---|
-Xms / -Xmx | Initial and maximum heap size. When they're equal, Java doesn't have to grow and shrink the heap later. |
-XX:+UseG1GC | Selects the G1 garbage collector. |
-XX:MaxGCPauseMillis=200 | Target pause time for GC. Not a hard limit, but a goal G1 tries to meet. |
-XX:+ParallelRefProcEnabled | Makes the reference processing step multithreaded. |
-XX:+DisableExplicitGC | Stops plugins from triggering a full GC with System.gc() calls. |
-XX:+AlwaysPreTouch | Reserves the heap in physical memory at startup, avoiding memory allocation delays while running. That's why startup takes a little longer. |
G1NewSizePercent / G1MaxNewSizePercent | Share of the heap reserved for the young generation. Minecraft's short-lived objects are cleaned up here. |
G1HeapRegionSize | G1 region size. On large heaps, bigger regions hold large objects more efficiently. |
G1ReservePercent | Share of memory kept free as a reserve against overflow. |
InitiatingHeapOccupancyPercent | How early old-generation collection starts. |
G1MixedGCCountTarget, G1MixedGCLiveThresholdPercent, G1HeapWastePercent | How often mixed GC cycles run and which regions get cleaned. |
SurvivorRatio=32, MaxTenuringThreshold=1 | Prevent short-lived objects from being needlessly promoted to the old generation. |
-XX:+PerfDisableSharedMem | Turns off the JVM writing its stats file to disk, preventing disk-related GC pauses. |
-Dusing.aikars.flags, -Daikars.new.flags | Labels only; they have no performance effect and just show in reports that the flags are in use. |
Setting Xms and Xmx based on your plan's RAM
The most common mistake is giving all of the plan's RAM to -Xmx. Java doesn't only use the heap: thread stacks, the JIT compiler, metaspace, network buffers, and Paper's native memory usage all take up space outside the heap. On game panels, the server usually runs in a container with a RAM limit; if total usage goes over that limit, the system kills the process and the server looks like it shut down without logging any error.
General rule (a guideline): leave 0.5-1 GB of headroom on small plans and 1.5-2 GB on large plans.
| Plan RAM | Recommended -Xms/-Xmx | Flag set |
|---|---|---|
| 2 GB | 1536M | Standard (12 GB and below) |
| 6 GB | 5G | Standard |
| 8 GB | 7G | Standard |
| 12 GB | 10G | Standard |
| 16 GB | 14G | Over-12 GB set |
| 24 GB | 22G | Over-12 GB set |
More RAM isn't always better. An oversized heap increases the area that has to be scanned on each GC cycle. Monitor how much memory your server actually uses with spark health; if usage keeps hitting the heap limit, raise it, and if it stays at about half, lowering it won't even hurt performance.
Adding the flags to the startup line in your panel
- Stop your server.
- Open your panel's startup settings. Some panels only have RAM and jar name fields, while others let you edit the full command line.
- If you can edit the full line, put the parameters above before
-jar. Anything after-jargoes to Minecraft, not Java, and has no effect. - Replace the jar name with your own file (such as
paper.jarorserver.jar). - Start the server and check the first lines of the console for errors.
If your panel only offers a RAM field and you can't enter extra JVM parameters, you can open a support ticket explaining what you need.
Startup script on your own server (Linux)
If you're running on a VDS, putting the line in a script makes management easier:
#!/bin/bash
cd /opt/minecraft
exec 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 paper.jar --nogui
Make the file executable with chmod +x start.sh. On Forge and NeoForge 1.17+ servers, the parameters go in the user_jvm_args.txt file, one per line; we show this method in our how to set up a CurseForge modpack server guide.
Which Java version should you use?
Aikar's flags work on every Java version that has G1GC, from Java 8 up to current releases. But the Java version is decided by your server's Minecraft version, not by the flags: 1.16.5 and earlier need Java 8, 1.18 through 1.20.4 need Java 17, and 1.20.5 and later need Java 21. Using the newest compatible Java also lets you benefit from years of G1GC improvements. Check which version you're using in the console or terminal:
java -version
Measuring the effect of the change
Judge JVM settings by measuring, not by feel. After applying the flags, follow these steps:
- Start the server with the new line and run it through at least one busy hour of play.
- Run
spark healthin the console and note memory usage and GC stats. - When lag is noticeable, take a profile of a few minutes with
spark profiler startand check how much of it is GC pauses in the report. - Compare with your earlier measurements. If periodic GC-related freezes went down, the settings are working.
Don't change more than one thing at a time. If you change the flags, your plugins, and server.properties values on the same day, you won't know which change made the difference.
Common situations
- “Unrecognized VM option” error: A parameter is misspelled or your Java version doesn't support it. When copying the line, check for broken dashes or stray spaces.
- Server startup got slower: That's normal, because
AlwaysPreTouchreserves the heap up front. - Should I use ZGC? On current Java versions, ZGC offers very short pauses but needs more memory and CPU. It's worth trying on servers with a lot of RAM; for most servers, Aikar's flags are the safe, proven default.
- The flags didn't fix my lag: Lag that isn't caused by GC (entities, redstone, plugins) can't be fixed with JVM settings. Follow our Minecraft server lag fix guide to diagnose it.
Next step: Pick enough RAM for your flags
Aikar's flags use your server's memory efficiently, but they can't create memory that isn't there. For a plugin survival server or a mid-size modpack, the OB-MC-4 Minecraft server with 12 GB of RAM fits the standard flag set in this guide exactly, with a 10 GB heap plus headroom for the operating system. OyunBulut plans run in our Istanbul data center and come with NVMe SSD storage, DDoS protection, and a web panel. If you're planning a smaller or larger setup, compare the Minecraft server plans; you can use the RAM recommendations in the table directly when choosing a plan. When you're ready, launch your server with OB-MC-4 and set up the startup line using this guide.
Frequently asked questions
What are Aikar's flags?
Aikar's flags are JVM startup parameters recommended by the Paper project that tune Java's G1 garbage collector on Minecraft servers to run with short pauses.
Should Xms and Xmx be the same?
Yes, with Aikar's flags it's recommended to keep them equal. That way Java doesn't grow and shrink the heap while running, and AlwaysPreTouch can reserve the memory at startup.
Can I give all of my plan's RAM to Xmx?
No. Java also uses memory outside the heap; if you give it all the RAM, the server can exceed its memory limit and shut down. Leave about 0.5-1 GB of headroom on small plans and 1.5-2 GB on large ones.
Do Aikar's flags work on Forge and Fabric servers?
Yes, the parameters are passed to Java regardless of the server software. On Forge and NeoForge 1.17 and later, they go in the user_jvm_args.txt file.
Why are different flags used above 12 GB of RAM?
On large heaps, the young generation share, region size, and reserve values are rebalanced. That's why five G1 parameters are raised for heaps larger than 12 GB.