ZGC Garbage Collector for Minecraft: ZGC vs G1GC 2026

Published on | Updated

ZGC or G1GC for your Minecraft server: when each wins, ZGC flags for Java 21 and Java 25, heap per plan size, and the flag that stops Java 26 from starting.

A Minecraft-style server room with long rows of glowing server racks

Your server hitches every few seconds, a guide tells you to switch to ZGC, and you want to know whether the Z Garbage Collector really beats G1GC for Minecraft and which flags to paste. Two things decide it: your server's memory and its Java version. Minecraft 26.1 and newer need Java 25, which changed the ZGC flags, and Java 26 refuses to start with a flag that many older guides still copy.

Quick answer: Keep G1GC with Aikar's flags on servers below 12 GB, and from 12 GB up, test ZGC when spark shows garbage collection pauses lining up with your lag. To use ZGC on a Minecraft server, replace every G1 flag with -XX:+UseZGC and set -Xms and -Xmx to the same value, 1.5 to 2 GB below your server's memory. Add -XX:+ZGenerational only on Java 21 (Minecraft 1.20.5 to 1.21.11). Java 25 (Minecraft 26.1 to 26.3) ignores it with a warning, and Java 26 and newer will not start with it.

Minecraft ZGC Arguments to Copy

The flags follow your Java version, not your Minecraft version, so check it with java -version or in your panel. Both lines are for a 16 GB server:

Java 25 and newer (Minecraft 26.1 to 26.3):

-Xms14G -Xmx14G -XX:+UseZGC -XX:+AlwaysPreTouch -XX:+DisableExplicitGC

Java 21 (Minecraft 1.20.5 to 1.21.11):

-Xms14G -Xmx14G -XX:+UseZGC -XX:+ZGenerational -XX:+AlwaysPreTouch -XX:+DisableExplicitGC

For other sizes, change both 14G values to the heap from the table below. The line replaces your old garbage collector flags and goes between java and -jar. None of these flags is experimental: ZGC has been a product feature since JDK 15 (JEP 377).

  • -XX:+UseZGC selects ZGC, and -XX:+ZGenerational switches Java 21 to its generational mode.
  • -Xms equal to -Xmx plus -XX:+AlwaysPreTouch claims the whole heap at startup. Oracle suggests this pairing when low latency is why you run ZGC, because committing and returning memory while the program runs can hurt latency (Oracle ZGC guide).
  • -XX:+DisableExplicitGC makes Java ignore System.gc() calls from plugins and mods.

What -XX:+UseZGC Does on Each Java Version

Mojang's version files list Java 17 for Minecraft 1.18 to 1.20.4, Java 21 for 1.20.5 to 1.21.11 and Java 25 for 26.1 to 26.3. Across those Java versions, ZGC went from one generation to two, and -XX:+ZGenerational went from required to fatal:

Java-XX:+UseZGC aloneWith -XX:+ZGenerational added
17Single-generation ZGC, the only modeUnrecognized option: Java does not start
21 and 22Single-generation ZGCGenerational ZGC (JEP 439)
23Generational ZGC (JEP 474)Generational, with a deprecation warning
24 and 25Generational ZGC, the only mode (JEP 490)Ignored with a warning
26 and newerGenerational ZGCUnrecognized option: Java does not start

On Java 24 and 25 the flag prints Ignoring option ZGenerational; support was removed in 24.0 and the server starts anyway. On Java 17 and on Java 26 or newer it prints Unrecognized VM option 'ZGenerational' and Java stops before Minecraft loads. The OpenJDK issue that removed it, JDK-8369983, says it stayed a warning through Java 25 because 25 is a long-term support release. Java 26 came out on 17 March 2026 and Java 27 on 15 September 2026, so a panel image or launcher that installs the newest Java turns a copied Java 21 line into a server that will not boot.

Generational mode suits Minecraft: it collects young objects more often, because they tend to die young (JEP 439), and PaperMC's docs put Minecraft's allocation at "at least 800MB/second on a 30 player server", mostly short-lived objects. Java 17 only has the older single-generation mode. JEP 439 lists a lower risk of allocation stalls, less heap overhead and less GC CPU as the goals of generational mode over it, and the old mode maps the heap three times, so tools such as ps show about triple the memory it uses. On Java 17, stay on G1.

G1GC vs ZGC: How Each One Pauses

Minecraft's game loop runs 20 times a second, so each tick has 50 milliseconds (Minecraft Wiki). When the garbage collector stops the server to free memory, the tick in progress waits, and a long stop shows up as a lag spike.

G1GC (Garbage-First) is Java's default collector on most hardware and the one Aikar's flags tune. It splits the heap into equal regions and first reclaims the ones that are mostly garbage, "therefore the name". It marks live objects while the server runs but copies them in stop-the-world pauses (Oracle G1 guide), with a pause goal of 200 ms by default (java command). Oracle says G1 is "not a real-time collector": it meets the goal with high probability, not every time.

ZGC does all its expensive work while the server keeps running and does not stop it for more than a millisecond, whatever the heap size (Oracle ZGC guide). There are two costs. Its GC threads use CPU the server could use, "at the cost of some throughput" in Oracle's words (Available Collectors). And the heap needs headroom, because the server keeps allocating during a collection: if it fills memory faster than ZGC frees it, threads wait, which is called an allocation stall. Oracle's advice: "the more memory you give to ZGC the better."

G1GC (Aikar's flags)ZGC
PausesStop-the-world young and mixed collections, 200 ms goalUnder a millisecond, independent of heap size
ThroughputAims for high throughput while meeting its pause goalSome throughput cost for the concurrent work
MemoryPaperMC recommends at least 6 to 10 GBNeeds headroom; -Xmx is the main tuning knob

Heap and Collector per Plan Size

These are starting points from the sources on this page, not benchmark results, for the memory sizes of our Minecraft plans, Standard and Premium alike. PaperMC's rule is to stay about 1000 to 1500 MB below your memory so Java and the system have room. The table leaves about 1.5 GB up to 8 GB and 2 GB from 12 GB up, where big modpacks keep more class data outside the heap, as in our ATM10 guide.

Server memory-Xms and -XmxCollector
3 GB1536MG1 with Aikar's flags
4 GB2560MG1 with Aikar's flags
5 GB3584MG1 with Aikar's flags
6 GB4608MG1 with Aikar's flags
8 GB6500M, PaperMC's own exampleG1 with Aikar's flags
12 GB10GG1; test ZGC if GC pauses match your lag
15 GB13GG1 or ZGC: test both under load
16 GB14GG1 or ZGC: test both under load
32 GB30GG1 or ZGC: test both under load

Below 12 GB, skip ZGC: it needs spare heap and CPU to keep up (JEP 439), and a small heap has little room to spare. The 12 GB line is our own starting point, not a JDK limit, and PaperMC warns that past a certain point more memory brings diminishing returns. On 8 GB, use Aikar's full line with -Xms6500M -Xmx6500M, as in our Aikar's flags guide.

How to Use ZGC on a Minecraft Server

  1. Check the Java version with java -version or in your panel. It decides whether -XX:+ZGenerational goes in.
  2. Remove every G1 setting: -XX:+UseG1GC, all -XX:G1... options, MaxGCPauseMillis, InitiatingHeapOccupancyPercent, SurvivorRatio, MaxTenuringThreshold, ParallelRefProcEnabled and -XX:+UnlockExperimentalVMOptions. From Aikar's set, -XX:+AlwaysPreTouch, -XX:+DisableExplicitGC, -XX:+PerfDisableSharedMem and the two -D entries are not G1 settings and can stay.
  3. Paste the ZGC line for your Java version before -jar, in your panel's startup or JVM arguments field. On Space-Node that is the Startup tab, where every plan takes custom JVM arguments and you also pick the Java version.
  4. Restart, check the first console lines for warnings or errors, then measure.

A half-done switch fails in one of three ways:

  • -XX:+UseG1GC left next to -XX:+UseZGC: Java stops with Multiple garbage collectors selected.
  • -XX:+UnlockExperimentalVMOptions removed but an experimental G1 option kept: Java stops with a message such as VM option 'G1NewSizePercent' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.
  • -XX:MaxTenuringThreshold=1 kept: the server starts, but generational ZGC uses that flag as the ceiling for the object age it picks itself, so Aikar's value caps it at 1. We read this in the JDK 21 and 25 source code; Oracle's guide says ZGC adjusts its tenuring thresholds on its own.

To go back, swap the ZGC flags for Aikar's full line. Worlds, plugins and configs are not touched either way.

Check That Garbage Collection Is Your Problem

A new collector only fixes lag that garbage collection causes, so check with spark first. Paper has bundled it since 1.21; on Fabric, Forge and NeoForge it is a mod (spark downloads).

  • /spark gc prints the server's GC history, and /spark gcmonitor toggles live GC monitoring.
  • /spark tickmonitor --threshold-tick 50 reports every tick over 50 ms, with GC activity unless you add --without-gc.
  • /spark tps prints TPS and CPU usage.

At a busy time on G1, note the players online, the longest GC pause, how often ticks pass 50 ms and your panel's memory. Switch to ZGC and repeat at a similar time with a similar crowd. Keep ZGC only if long G1 pauses lined up with your spikes and are now gone; lag from entities, redstone or chunk generation needs other fixes.

For a lasting record, add PaperMC's GC log flag from our Aikar's flags guide; it works with ZGC too. Search that log for Allocation Stall: each such line means a thread waited for ZGC to free memory. If they show up while players are online, ZGC needs a bigger heap, which on a hosted server means more memory, or go back to G1.

What About Shenandoah?

Shenandoah is OpenJDK's other low-pause collector, next to ZGC. Red Hat shipped it in its Java 8 and 11 builds before it joined OpenJDK 12, and it has been a product feature since JDK 15 (JEP 379). Its wiki says "Garbage collecting a 200 GB heap or a 2 GB heap should have the similar low pause behavior" (Shenandoah wiki).

Still, try ZGC first on Java 25, for two reasons. Shenandoah's generational mode became a product feature in Java 25 (JEP 521) but is not its default, so you add -XX:ShenandoahGCMode=generational to -XX:+UseShenandoahGC yourself. And Oracle does not ship Shenandoah in any of its builds, while Amazon Corretto, Azul Zulu and Red Hat's builds do; without it, Java stops with Option -XX:+UseShenandoahGC not supported. If your JDK has it, test it like ZGC: no G1 flags, then measure.

FAQ

Is ZGC a mod for Minecraft? No. ZGC is part of Java, so there is nothing to download on Modrinth or CurseForge. You turn it on with -XX:+UseZGC in the server's start line or, for the game on your PC, in the launcher's Java arguments: Custom Java arguments in an instance's Java and memory settings in the Modrinth App, or Additional Arguments in the CurseForge app's Minecraft settings or a modpack's Profile Options. The same Java version rules apply.

Do I still need -XX:+ZGenerational? Only on Java 21 (and 22), which Minecraft 1.20.5 to 1.21.11 use. Java 23 to 25 run generational ZGC without it, and 24 and 25 ignore it with a warning. Java 17 and Java 26 or newer refuse to start with it, so remove it everywhere else.

Is it normal for ZGC to use 98% of memory? Usually, yes. With -Xms equal to -Xmx and -XX:+AlwaysPreTouch, Java claims the whole heap at startup, so your panel shows it as used from the first minute, whatever the collector, and ZGC never returns memory below -Xms (Oracle ZGC guide). On Java 17, ps even shows about three times the heap. The percentage says nothing about lag: check spark's tick times and the GC log for Allocation Stall lines.

ZGC or G1GC for ATM10? All The Mods 10 runs on Minecraft 1.21.1, so on Java 21, and a ZGC line for it needs -XX:+ZGenerational. Start with the G1 flags the pack ships; on 12 GB or more, test ZGC when spark shows GC pauses lining up with your lag. Our ATM10 JVM arguments guide has a ZGC line for the pack and memory per player count.

What is the G1 garbage collector in Minecraft? G1 (Garbage-First) is the collector Java uses by default on most hardware, so it runs your server unless a flag picks another. It splits the heap into equal regions, reclaims the mostly-garbage ones first and aims to keep pauses under 200 ms by default. Aikar's flags, which PaperMC recommends, tune G1 for Minecraft.

Sources

All opened on 31 October 2026:


Legal Notice

Legal Notice & Disclaimer: This article constitutes an independent, factual comparative review and critical analysis for educational purposes only. Space-Node is not affiliated with, endorsed by, or sponsored by any hosting provider mentioned herein. All brand names, logos, and trademarks referenced are the registered intellectual property of their respective owners and are used solely for identification and factual reference.

Fair Use & Review Rights: This review is protected commentary, comparison, and criticism. It is based on publicly available information, official pages where available, published documentation, and general hosting engineering analysis. Where hands-on testing is not explicitly stated in the article, no private benchmark or internal infrastructure access is implied. This constitutes lawful comparative review and criticism protected under fair use doctrine.

Factual Accuracy: Specific plan claims are based on public information available at the time of writing. Specifications, pricing, and service features can change, so readers should verify current details on the provider's official website before purchasing. We make no false or defamatory statements; criticism is limited to documented facts, clearly labeled opinion, or general hosting guidance.

No Consumer Confusion: This article makes clear that Space-Node offers distinct, independently-developed hosting infrastructure. We explicitly differentiate our services, pricing, and technical specifications. No reader could reasonably be confused about service provider identity.

Right to Comparative Advertising: Space-Node reserves the right to publish factual comparative information about competing services. This is a recognized right in consumer protection law and advertising standards. Accurate comparative reviews cannot constitute trademark violation, defamation, or unfair competition.

Limitation of Liability: Space-Node makes no warranty regarding third-party services reviewed. Readers are responsible for verifying information independently before purchasing. Space-Node disclaims liability for third-party service changes, outages, or policy modifications.

Space-Node Services: For Space-Node's own managed hosting solutions, visit Minecraft hosting or VPS hosting.