Skip to content
Tools

// Server

Startup Flags

Generate a start script with tuned JVM flags for your RAM, Java version and server software.

Memory for the server
GB

The Java heap, set as both Xms and Xmx. The machine needs more than this.

Server software
Java
Garbage collector

Aikar's flags, as PaperMC publishes them.

The machine
GB in all

Optional. With it, you're told if Java has too little room beyond the heap.

Script
Where it goes

start.sh

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

#!/usr/bin/env sh

# Run from the folder this script is in.
cd "$(dirname "$0")"

java -Xms8G -Xmx8G -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

What the flags do

  • Xms and Xmx set the heap: the memory Java keeps the server's objects in. Xmx is the most it may use; Xms is how much it takes at the start.
  • Aikar's flags tune the G1 collector for how Minecraft uses memory: it makes a huge amount of short-lived garbage (block positions, packets), so they give the young generation far more room, collect it in pauses of up to 200ms (four ticks at most), and stop plugins forcing a full collection with System.gc(). PaperMC explains each one on its Aikar's flags page. Over 12GB, a few values change to suit the bigger heap.
  • Generational ZGC collects almost entirely alongside the server, so pauses stay under a millisecond, at the cost of more CPU and memory. It's worth trying on big heaps (16GB and up) with cores to spare. On Java 21 it needs -XX:+ZGenerational; from Java 23 that's the default and the flag is deprecated, so it's left out.
  • Proxies (Velocity, BungeeCord, Waterfall) get Velocity's recommended flags. A proxy holds no worlds, so it needs far less memory: about 512MB per 500 players, plus 1GB.

Why Xms equals Xmx

Plan for the server to use all of Xmx, because in time it will. Then a lower Xms saves nothing: it only makes Java grow the heap in steps while you play, and G1 works better with all its room from the start. -XX:+AlwaysPreTouch claims the whole heap at launch, so if the machine can't hold it you find out then, not at peak hours.

Leave memory for Java itself

Java uses memory outside the heap: threads, compiled code, the collector's own tables and network buffers. Leave 1 to 1.5GB, or 10 to 15%, beyond Xmx: on an 8GB machine give the server about 6.5GB. In a container the limit is hard and going over gets the server killed without a crash report, so leave more, around a fifth.

On a VPS or your own machine

  • Linux: save start.sh in the server folder, run chmod +x start.sh once, then ./start.sh. Run it inside screen or tmux so it keeps going when you log out.
  • Windows: save start.bat in the server folder and double-click it. pause keeps the window open if it stops, so you can read why.
  • With the restart loop, /stop restarts the server after five seconds. Press Ctrl+C during the wait to stop for good.
  • Forge and NeoForge from 1.17 have no server jar: the installer writes run.sh and user_jvm_args.txt. The script here writes the flags into that file and then calls run.sh.

On Pterodactyl

  • The startup command is on the server's Startup tab. Only an admin can change it: on a hosted panel, ask your host, or paste just the flags if they give you a field for them.
  • {{SERVER_MEMORY}} is the memory you set for the server in MB, and {{SERVER_JARFILE}} is the egg's jar variable. The panel's startup script expands the line, so the heap is worked out from the memory: 85% of it for a server and half for a proxy, as Velocity advises. Wings already lets the container go 5 to 15% over that figure, but that alone is less than Java needs.

On Docker

  • The compose file is for itzg/minecraft-server, or itzg/mc-proxy for a proxy. It sets MEMORY (both Xms and Xmx) and turns on the image's own USE_AIKAR_FLAGS, which follows the same 12GB rule. ZGC and proxy flags go in JVM_XX_OPTS.
  • The image tag picks the Java version. With the machine's memory and Container set, it also sets mem_limit; itzg suggests a container a quarter bigger than the heap.

Good to know

  • Minecraft 26.1 and later need Java 25, 1.20.5 to 1.21.11 need Java 21, and 1.18 to 1.20.4 need Java 17, from the Java version Mojang lists for each release.
  • More memory isn't always faster: PaperMC says the returns shrink past a point, and that 32GB "will only waste your money". If the server still lags, a profile from spark shows where the time goes.
  • Writing the server list message next? The MOTD Generator