Minecraft JVM arguments generator

JVM arguments tell Java how much memory Minecraft gets and how to clean it up. Pick your server and its memory for Aikar's flags in a start script, with a heap that leaves Java the room it needs.

Free · Nothing leaves your browser · Updated 28 Sep 2026

Turn on JavaScript to make arguments for your server. What each of Aikar's flags does is below.

Your setup

Arguments for

Runs on Java 25

Server software
8 GB

Your host's plan, or what the machine can spare for it.

Flags

G1, tuned for Minecraft: what Paper recommends and Playkeeper uses.

Options

The .jar file in the server's folder.

Your arguments

6 GB heap, the -Xmx2 GB for Java itself and the system

start.sh
#!/usr/bin/env sh
# A 6 GB heap with Aikar's flags, on Java 25. playkeeper.io/tools/jvm-flags
cd "$(dirname "$0")"
java -Xms6144M -Xmx6144M -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

Save it next to paper.jar, run chmod +x start.sh once, then ./start.sh.

start.sh6 GB heap · Aikar's flags

Start your server with it

On Linux, macOS or Windows, or in a host's panel, with any Java from 8 to 25.

Where it goes

  1. Linux and macOS: start.sh

    Save it next to the server's jar, run chmod +x start.sh once, then ./start.sh to start.

  2. Windows: start.bat

    Save it next to the server's jar and double-click it.

  3. NeoForge and Forge: user_jvm_args.txt

    Replace what's in the file the installer made, then start with ./run.sh nogui, or run.bat nogui on Windows.

  4. A host's panel: Flags only

    Paste them where the panel takes JVM arguments.

If it won't start

  • UnsupportedClassVersionErrorThe server needs a newer Java. The class file version in the message names it: 61 is Java 17, 65 is Java 21 and 69 is Java 25.
  • Error opening log file 'logs/gc.log'Java 11 and newer won't start while the GC log's folder is missing. Make a logs folder next to the server; the scripts made here do.
  • Unrecognized VM optionYour Java doesn't have that flag: -XX:+UseCompactObjectHeaders needs Java 25, and -XX:+ZGenerational Java 21.
  • Could not reserve enough space for object heapJava can't get that much memory: the heap is bigger than the machine has free, or the Java is 32-bit.
  • It just says KilledThe system ran out of memory and stopped Java. Give the heap less, so Java has room outside it.

What each of Aikar's flags does

They tune G1, Java's garbage collector, for how Minecraft uses memory. From 12 GB of heap, five take larger values.

-Xms and -Xmx
The heap, where Minecraft keeps what it's working on. The same size for both means Java takes it all at the start and never has to grow it.
-XX:+UseG1GC
Uses G1, the garbage collector the rest tune. Java only picks it itself on a machine with at least 2 cores and about 2 GB of memory.
-XX:+ParallelRefProcEnabled
Clears weak and soft references with several threads, so pauses are shorter.
-XX:MaxGCPauseMillis=200
Aims for pauses of at most 200 ms, 4 ticks, which the server makes up for at once.
-XX:+UnlockExperimentalVMOptions
Allows G1NewSizePercent and G1MaxNewSizePercent, which Java counts as experimental.
-XX:+DisableExplicitGC
Ignores plugins that ask for a full collection, which would freeze the server.
-XX:+AlwaysPreTouch
Takes all of the heap from the system at start, so none is handed out slowly during play.
-XX:G1NewSizePercent=3012 GB or more: 40
Keeps at least this share of the heap for new objects: Minecraft makes hundreds of megabytes of short-lived ones a second.
-XX:G1MaxNewSizePercent=4012 GB or more: 50
Keeps at most this share of the heap for new objects.
-XX:G1HeapRegionSize=8M12 GB or more: 16M
Splits the heap into regions this big, so fewer objects count as humongous and go straight to the old generation.
-XX:G1ReservePercent=2012 GB or more: 15
Keeps this share free for moving objects during a collection, so it never runs out of room to copy them.
-XX:G1HeapWastePercent=5
Stops cleaning the old generation once no more than 5% of the heap would be freed.
-XX:G1MixedGCCountTarget=4
Cleans old regions within 4 mixed collections instead of 8, so they're free sooner.
-XX:InitiatingHeapOccupancyPercent=1512 GB or more: 20
Starts marking the old generation when the heap is this full, instead of 45%.
-XX:G1MixedGCLiveThresholdPercent=90
Lets mixed collections clean old regions up to 90% full, where Java's default stops at 85% or lower.
-XX:G1RSetUpdatingPauseTimePercent=5
Spends 5% of each pause on bookkeeping instead of 10%, and does more of it while the game runs.
-XX:SurvivorRatio=32
Makes the survivor spaces small, as MaxTenuringThreshold=1 leaves little in them.
-XX:+PerfDisableSharedMem
Stops Java writing statistics to a file, which can stall the server when the disk is busy.
-XX:MaxTenuringThreshold=1
Moves objects that survive two collections to the old generation, instead of copying them up to 15 times.
-Dusing.aikars.flags=https://mcflags.emc.gs
A label: it changes nothing, and tells anyone reading the arguments, in a spark report say, that these are Aikar's flags.
-Daikars.new.flags=true
Another label, for this version of the flags.

Playkeeper starts every server this way

Aikar's flags, the Java its Minecraft version needs and a heap sized as it is here. Settings › Memory then suggests a size from what the server needed over the last 14 days.

curl -fsSL https://playkeeper.io/install | sudo sh
A server's Memory in Playkeeper's Settings: it never needed more than 2.5 GB in the last 14 days, so 4 GB is plenty, over a chart of each day's peak.

Questions

What are the best JVM arguments for a Minecraft server?

For most servers, Aikar's flags, with -Xms and -Xmx set to the same heap and room left for Java outside it. Paper recommends them. On Java 17 or newer it also suggests trying Java's defaults first, and Aikar's flags if garbage collection makes the server lag.

How much memory should -Xmx get?

Less than the server has. Java needs memory outside the heap for its own code, threads and network buffers, and a host stops the server when it goes over. This tool leaves a quarter outside, at least 512 MB and more for mod loaders, as Playkeeper does. Paper suggests leaving about 1,000 to 1,500 MB.

Should -Xms and -Xmx be the same?

Yes, on a server. Java then takes the whole heap at the start and never resizes it, and G1 makes better use of memory it has than of memory it might get.

Do Aikar's flags still work on Java 21 and 25?

Yes. Every one of them starts on Java 8, 16, 17, 21 and 25 without a warning. From 12 GB of heap, use Aikar's larger values, as this tool does.

Aikar's flags or ZGC?

Aikar's flags tune G1, which Paper recommends and Playkeeper uses. ZGC pauses the server for under a millisecond, but needs more memory headroom and processor time. Its generational mode needs Java 21, so Minecraft 1.20.5 or newer. Since 26.1 the Minecraft Launcher starts the game itself with ZGC.

What JVM arguments does the Minecraft Launcher use?

Since 26.1, on computers that support ZGC: -Xms4G -Xmx4G -XX:+UseCompactObjectHeaders -XX:+AlwaysPreTouch -XX:+UseStringDeduplication -XX:+UseZGC, 4 GB with ZGC. Before that: -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M, 2 GB with G1. To give the game more memory, change only the numbers.

Why won't my server start after adding the GC log flag?

Java 11 and newer refuse to start when the log's folder doesn't exist yet, with Error opening log file 'logs/gc.log'. Make a logs folder next to the server first. The start scripts made here do it for you.

What Java does my Minecraft version need?

Java 8 up to 1.16.5, Java 16 for 1.17, Java 17 up to 1.20.4, Java 21 up to 1.21.11 and Java 25 from 26.1. The tool shows it as you type the version.

Does Playkeeper use Aikar's flags?

Yes. Every server starts with them, on the Java its Minecraft version needs, with a heap sized from its memory the way this tool sizes it. Playkeeper also logs its garbage collection, and Settings › Memory suggests a size from that.

Your server is one command away.

Free and open source. Friends can be playing tonight.

curl -fsSL https://playkeeper.io/install | sudo sh
Try the live demo