Guide · Configuration

Startup flags explained: Aikar's flags and memory settings

The startup command tells Java how much memory to use and how to manage it. The right flags reduce lag spikes from garbage collection; the wrong ones can make a good server stutter or crash.

Memory: -Xms and -Xmx

-Xmx is the maximum heap Java may use and -Xms the starting size. For a Minecraft server, set them to the same value so Java does not keep resizing the heap.

Do not give Java all of the machine's or container's memory. Java uses memory outside the heap too, for threads, native libraries and the garbage collector. Leave around 1 to 1.5 GB of headroom, more on large modpacks, or the operating system or container may kill the process when it goes over.

Aikar's flags

Aikar's flags are a tuned set of G1 garbage collector settings that most Paper servers use. They make collections shorter and more frequent, which shows up as fewer noticeable freezes. For heaps up to about 12 GB:

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

Above 12 GB

For larger heaps, change G1NewSizePercent to 40, G1MaxNewSizePercent to 50, G1HeapRegionSize to 16M, G1ReservePercent to 15 and InitiatingHeapOccupancyPercent to 20. Very few servers need more than 12 GB; if yours does, check that the memory is really in use before adding more.

Putting it together

A complete command looks like java -Xms6G -Xmx6G followed by the flags, then -jar server.jar --nogui. On a hosted server you usually do not write this by hand: the panel builds the command from your plan's memory and a startup template, and on StormNodes the Startup page shows the variables you can change.

What flags will not fix

Flags tune garbage collection. They do not fix a plugin that blocks the main thread, a redstone clock or an oversized view distance. If the server lags with free memory, profile it with spark before touching flags.

StormNodes Minecraft hosting

Run it on a StormNodes server

Skip the port forwarding and the PC that has to stay on. A StormNodes Minecraft server is online in minutes, and everything in this guide can be done from the panel.

  • Hosted in Portugal, close to players across Western Europe
  • NVMe storage, monthly billing and no setup fee
  • Paper, Purpur, Fabric and vanilla, switchable from the panel
  • Live console, file manager, SFTP, backups and schedules
  • Support in English and Portuguese

FAQ

Frequently asked questions

Should -Xms and -Xmx be the same?
Yes, for a dedicated Minecraft server. It avoids heap resizing and pairs well with AlwaysPreTouch in Aikar's flags.
Do Aikar's flags work on Java 21 and 25?
Yes. They are G1 settings and work on current Java versions. Some newer collectors exist, but G1 with these flags remains the safe default for most servers.
Can I give Java all of my server's RAM?
No. Leave 1 to 1.5 GB for memory Java uses outside the heap, or the process can be killed for exceeding its limit.