# Aikar's JVM Flags for Minecraft Servers Explained (/docs/minecraft/jvm-flags)



import { Step, Steps } from 'fumadocs-ui/components/steps';

**Aikar's flags** are a community-maintained set of JVM (Java Virtual Machine) arguments that optimize garbage collection for Minecraft servers. They're considered the **gold standard** for server performance and reduce TPS lag spikes by 50–80% on most setups.

What They Do [#what-they-do]

| Optimization              | Effect                                                                              |
| ------------------------- | ----------------------------------------------------------------------------------- |
| **Switch to G1GC**        | Replaces Java's default garbage collector with one designed for low-pause workloads |
| **Reduce GC pause times** | Eliminates the periodic stutters caused by full garbage collection                  |
| **Optimize allocation**   | Tunes new-generation sizing for Minecraft's allocation patterns                     |
| **Pre-touch memory**      | Allocates and touches all memory at startup so the OS doesn't reclaim it            |
| **Disable explicit GC**   | Prevents poorly-written plugins from triggering full GCs manually                   |

Apply Aikar's Flags [#apply-aikars-flags]

<Steps>
  <Step>
    Open Startup [#open-startup]

    In the [XGamingServer Panel](https://panel.xgamingserver.com), click **Startup** in the sidebar.
  </Step>

  <Step>
    Find the JVM Flags field [#find-the-jvm-flags-field]

    Look for **JVM Flags**, **Additional Java Arguments**, or **Java Options** — the exact label varies. This is where startup JVM arguments go.
  </Step>

  <Step>
    Paste the flags [#paste-the-flags]

    Copy the appropriate flag set below (depending on your RAM allocation) and paste it into the field.
  </Step>

  <Step>
    Restart the server [#restart-the-server]

    Restart from **Console**. The new flags take effect immediately.
  </Step>
</Steps>

The Flags [#the-flags]

For Servers with 12 GB RAM or Less [#for-servers-with-12-gb-ram-or-less]

```
-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
```

For Servers with More Than 12 GB RAM [#for-servers-with-more-than-12-gb-ram]

Use the same flags but **change these two values**:

```
-XX:G1NewSizePercent=40
-XX:G1MaxNewSizePercent=50
```

This is because larger heaps benefit from a bigger young generation.

Verify the Flags Are Active [#verify-the-flags-are-active]

In the **Console**, look for the startup log. With Aikar's flags applied, you should see:

```
[main/INFO] Starting net.minecraft.server.Main
[main/INFO] [System Property] using.aikars.flags = https://mcflags.emc.gs
[main/INFO] [System Property] aikars.new.flags = true
```

The two `using.aikars.flags` and `aikars.new.flags` properties confirm the flags loaded correctly.

Do They Actually Help? [#do-they-actually-help]

**Yes — measurably.** The biggest improvement is reducing **TPS lag spikes** caused by JVM garbage collection pauses. Without these flags, you'll see periodic stutters every 30 seconds to a few minutes. With them, GC happens incrementally and players don't notice.

Common before/after:

| Without Aikar's                            | With Aikar's                         |
| ------------------------------------------ | ------------------------------------ |
| GC pause: 200–500 ms every minute          | GC pause: 20–50 ms every few seconds |
| TPS dips to 15 during GC                   | TPS stays at 19.5+ during GC         |
| Players see "rubber banding" during pauses | Smooth gameplay                      |

Common Mistakes [#common-mistakes]

| Mistake                      | Why It's Wrong                                                                                        |
| ---------------------------- | ----------------------------------------------------------------------------------------------------- |
| **Over-allocating RAM**      | Giving 16 GB to a 4-player server makes GC pauses **worse**, not better. Match RAM to actual need     |
| **Mixing GC flags**          | Don't use Aikar's flags AND `-XX:+UseConcMarkSweepGC` or other GC settings — they conflict            |
| **Using old CMS collector**  | `-XX:+UseConcMarkSweepGC` is the legacy CMS collector that Aikar's flags specifically replace         |
| **Forgetting `-Xms = -Xmx`** | Min and max heap should match, e.g. `-Xms6G -Xmx6G`. Different values cause runtime resizing overhead |

Java Version Notes [#java-version-notes]

Aikar's flags work on **Java 8, 17, and 21**. The G1 collector is available in all modern Java versions. No flag changes are needed across Java upgrades.

Reference [#reference]

* **Aikar's original blog post**: [aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft](https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/)
* **Updated flags reference**: [mcflags.emc.gs](https://mcflags.emc.gs)

Related Guides [#related-guides]

* [Performance Optimization](/docs/minecraft/optimize-server)
* [How Much RAM](/docs/minecraft/how-much-ram)
* [Java Version](/docs/minecraft/java-version)
* [Spark Profiler](/docs/minecraft/setup-spark)
* [Types of Server Lag](/docs/minecraft/types-of-server-lag)
