Performance • 2026-08-19 • 6 min read

The Best JVM Flags for Minecraft Servers (2026 Edition)

Maximize TPS and eliminate Garbage Collection lag spikes on your Minecraft server using the latest optimized Java 21+ JVM startup arguments.

The Best JVM Flags for Minecraft Servers (2026 Edition)

Garbage Collection (GC) pauses are one of the most common reasons why a Minecraft server periodically stutters or drops frames even when CPU usage appears low.

Default Java Virtual Machine (JVM) flags are designed for generic background server applications—not real-time, tick-based game loops that allocate and discard millions of short-lived Java objects every second.

Here are the tested, production-grade JVM arguments for Minecraft 1.20 and 1.21+ running Java 21.


1. The Standard Production Flags (G1GC)

For almost all Minecraft servers allocated between 4 GB and 16 GB of RAM, the battle-tested Aikar G1GC flags deliver the smoothest tick times:

java -Xms8G -Xmx8G \
  -XX:+UseG1GC \
  -XX:+ParallelRefProcEnabled \
  -XX:MaxGCPauseMillis=200 \
  -XX:+UnlockExperimentalVMOptions \
  -XX:+DisableExplicitGC \
  -XX:+AlwaysPreTouch \
  -XX:G1NewSizePercent=30 \
  -XX:G1MaxNewSizePercent=40 \
  -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 \
  -jar server.jar --nogui

2. What Each Critical Flag Actually Does

-XX:+AlwaysPreTouch

Forces Java to allocate and zero out all specified RAM (-Xmx) immediately at startup rather than on-demand during gameplay. This prevents massive stutter when new players join or explore new dimensions.

-XX:+UseG1GC

Enables the Garbage-First (G1) collector, which breaks memory into discrete regions and collects the regions with the most garbage first, keeping individual GC pauses below 200ms (-XX:MaxGCPauseMillis=200).

-XX:InitiatingHeapOccupancyPercent=15

Starts the marking cycle early (at 15% memory occupancy) so old objects are collected continuously before heap pressure causes a full stop-the-world GC freeze.


3. High-RAM Servers (16GB+): Should You Use Generational ZGC?

If you run huge modded packs (ATM9, DawnCraft) or network hubs with over 16 GB of RAM, Java 21 introduces Generational ZGC (-XX:+UseZGC -XX:+ZGenerational), boasting sub-millisecond pause times:

java -Xms16G -Xmx16G \
  -XX:+UseZGC \
  -XX:+ZGenerational \
  -XX:+AlwaysPreTouch \
  -XX:+DisableExplicitGC \
  -jar server.jar --nogui

[!WARNING] While ZGC yields virtually zero pause time, it consumes slightly more CPU throughput than G1GC. For standard SMPs with 6GB–10GB of RAM, G1GC remains the recommended choice.


4. Common Flag Mistakes to Avoid

  1. Allocating too much RAM: Giving a vanilla or light Paper server 24GB of RAM will actually degrade performance because G1GC will accumulate gigabytes of junk before triggering large, laggy cleanup cycles. Stick to 6GB–10GB unless running massive modpacks.
  2. Mismatching -Xms and -Xmx: Always set both to the same number (e.g. -Xms8G -Xmx8G).
  3. Using outdated CMS flags: ConcurrentMarkSweep (-XX:+UseConcMarkSweepGC) has been deprecated and removed in modern Java versions.