Guides / Startup flags

G1GC vs ZGC for Minecraft servers

Should a Minecraft server use G1 (Aikar's flags) or ZGC? When each makes sense, and the flags for both.

Updated

G1 with Aikar's flags is the safe default for almost every Minecraft server. ZGC can help some large servers, but needs more RAM and a modern Java.

G1 (Aikar's flags)

  • Tested on Minecraft servers for years, and recommended by PaperMC
  • Works on Java 8 and newer
  • Short pauses, usually well under 50 ms with the flags
  • Efficient with memory

Generate a set with the startup flags generator.

ZGC

ZGC keeps pauses to around a millisecond whatever the heap size, at the cost of more CPU and memory overhead.

  • Needs Java 21 or newer for the generational version
  • Works best with plenty of spare memory and CPU cores
  • Can help large modded servers with big heaps (16 GB+)

On Java 21:

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

On Java 23 and newer, generational mode is the default, so leave out -XX:+ZGenerational.

Which should you use?

  • Under 12 GB, or a small or medium server: G1 with Aikar's flags
  • 16 GB+ with spare CPU cores, and lag spikes you've traced to garbage collection: try ZGC and compare

Test, don't guess

Use the spark profiler to check how long garbage-collection pauses really are before and after the change. If G1 pauses are already short, ZGC won't feel any different.

Work it out for your server

The free Startup flags generator gives you the exact settings for your setup.

Open the Startup flags generator →