---
title: "ZGC for Minecraft Servers: Flags, Java Versions, G1 Choice"
description: "Should your Minecraft server use ZGC or G1 with Aikar's flags? Learn the flags for Java 21 and 25, the tradeoffs and how to test the change."
url: "https://www.zcraftstudios.com/blog/zgc-minecraft-server-flags-guide"
updated: "2026-10-27T04:59:29.068351+00:00"
source: "ZCraft Studios"
---

> Site index for AI agents: https://www.zcraftstudios.com/llms.txt (full reference: https://www.zcraftstudios.com/llms-full.txt). Every page is available as Markdown by adding `.md` to its URL or sending `Accept: text/markdown`.

1. [Home](https://www.zcraftstudios.com/)
2. [Blog](https://www.zcraftstudios.com/blog)
3. ZGC for Minecraft Servers: Flags, Java Versions, G1 Choice

[ All posts](https://www.zcraftstudios.com/blog)

# ZGC for Minecraft Servers: Flags, Java Versions, G1 Choice

ZCraft StudiosOct 27, 2026

Should your Minecraft server use ZGC or G1 with Aikar's flags? Learn the flags for Java 21 and 25, the tradeoffs and how to test the change.

## In this guide

- [What a garbage collector does](#what-a-garbage-collector-does)
- [Java version rules for ZGC](#java-version-rules-for-zgc)
- [Example flags](#example-flags)
- [G1 or ZGC: how to choose](#g1-or-zgc-how-to-choose)
- [Test it properly](#test-it-properly)
- [Common mistakes](#common-mistakes)
- [Frequently asked questions](#frequently-asked-questions)
- [Related reading](#related-reading)

## ZGC for Minecraft Servers: Flags, Java Versions and When to Use It

**Quick answer:** most Minecraft servers should keep **G1 with Aikar's flags**, which is what Paper's documentation recommends. ZGC is an alternative that aims for very short pauses, and it can help servers with large heaps that suffer from garbage collection spikes. It needs spare CPU and a modern Java. Test it against G1 with a profiler instead of assuming it is faster.

## What a garbage collector does

Java frees memory automatically. The garbage collector (GC) occasionally pauses work to clean up. On a Minecraft server a long pause becomes a missed tick, so players feel it as a lag spike. Minecraft allocates many short-lived objects, which makes GC choice matter.

| Collector | Pause behavior | Notes |

| --- | --- | --- |

| G1 (default) | Short, regular pauses | Aikar's flags tune it for Minecraft |

| ZGC | Almost fully concurrent, very short pauses | Needs spare CPU, works best on larger heaps |

| Shenandoah | Concurrent compaction | Less common for Minecraft |

## Java version rules for ZGC

| Java | ZGC status |

| --- | --- |

| 17 | Non-generational ZGC only. Not recommended for Minecraft |

| 21 | Generational ZGC available with `-XX:+ZGenerational` |

| 23 | Generational ZGC becomes the default |

| 24 and later | Non-generational ZGC removed |

Minecraft 26.1 and newer require **Java 25**, so generational ZGC is what you get there. On Java 21, forgetting `-XX:+ZGenerational` gives you the older non-generational mode, which is a worse fit for Minecraft.

## Example flags

On Java 21 (Minecraft 1.21.x), a minimal ZGC setup looks like this:

```
java -Xms16G -Xmx16G \
  -XX:+UseZGC -XX:+ZGenerational \
  -XX:+AlwaysPreTouch -XX:+DisableExplicitGC \
  -jar paper.jar --nogui
```

On Java 25, generational mode is the default and the `ZGenerational` option is deprecated, so leave it out:

```
java -Xms16G -Xmx16G \
  -XX:+UseZGC \
  -XX:+AlwaysPreTouch -XX:+DisableExplicitGC \
  -jar paper.jar --nogui
```

Keep it simple. ZGC is designed to need little tuning, and adding many flags blindly can make it worse. Set `-Xms` equal to `-Xmx` so the heap does not resize.

For G1, use the current flags from the [Paper documentation](https://docs.papermc.io/paper/aikars-flags) and see [Aikar's Flags Explained](https://www.zcraftstudios.com/blog/aikars-flags-performance-tuning).

## G1 or ZGC: how to choose

| Situation | Lean toward |

| --- | --- |

| Small or medium heap, a few GB | G1 with Aikar's flags |

| Large heap with spikes you have measured | Test ZGC |

| CPU is already maxed | G1, because ZGC uses extra CPU |

| You want the safest, best-documented option | G1 |

| Minecraft 26.1+ on Java 25 | Either, test both |

ZGC trades some throughput and memory overhead for shorter pauses. Public comparisons usually show better worst-case pauses with ZGC and a slight average-throughput edge for G1 on small heaps, but results depend on your server and plugins.

## Test it properly

1. Make a staging copy. See [Staging Environment Guide](https://www.zcraftstudios.com/blog/minecraft-server-staging-environment-guide).
2. Run the server with G1 and capture a [spark](https://www.zcraftstudios.com/blog/how-to-read-spark-profiler-minecraft) profile and GC statistics during peak play.
3. Switch to ZGC, run the same load, and capture again.
4. Compare MSPT, TPS and GC pause times. See [TPS vs Ping vs FPS](https://www.zcraftstudios.com/blog/minecraft-server-tps-vs-ping-vs-fps).
5. Watch memory. ZGC uses more memory overhead, so leave headroom. See [RAM and Java Errors](https://www.zcraftstudios.com/blog/minecraft-java-heap-ram-errors).
6. Keep the change only if it measurably helps.

## Common mistakes

- Using ZGC on Java 17 or on Java 21 without generational mode
- Copying flag lists that mix G1 and ZGC options
- Allocating all of the machine's RAM to the heap
- Judging by feel instead of measuring
- Changing the collector to fix lag caused by a plugin or entities. See [Fix Minecraft Server Lag](https://www.zcraftstudios.com/blog/reduce-minecraft-server-lag)

## Frequently asked questions

**Is ZGC better than G1 for Minecraft?** Not automatically. It can reduce pauses on large heaps, but G1 with Aikar's flags is the safe default.

**Do I need ZGC on Minecraft 26.1?** No. G1 remains the default collector there.

**What Java version do I need for ZGC?** Java 21 or newer for generational ZGC.

**Should I use Aikar's flags with ZGC?** No. Aikar's flags are tuned for G1.

**Will ZGC fix my lag?** Only if GC pauses are the cause. Profile first.

## Related reading

- [Update a Minecraft Server to 26.1+](https://www.zcraftstudios.com/blog/minecraft-26-1-server-update-guide)
- [Minecraft Server Lag: Find the Cause, Then Fix It](https://www.zcraftstudios.com/blog/reduce-minecraft-server-lag)
- [Dedicated Server vs VPS](https://www.zcraftstudios.com/blog/minecraft-dedicated-server-vs-vps)

## Continue reading

- [Update a Minecraft Server to 26.1+: Java 25, Paper, Plugins](https://www.zcraftstudios.com/blog/minecraft-26-1-server-update-guide)
- [Update a Paper Plugin for Minecraft 26.1: Java 25 Guide](https://www.zcraftstudios.com/blog/update-paper-plugin-to-minecraft-26-1)
- [Aikar's Flags Explained: Do You Need Them, and How to Check](https://www.zcraftstudios.com/blog/aikars-flags-performance-tuning)
- [How to Start a Minecraft Server: Step-by-Step (Java, 2026)](https://www.zcraftstudios.com/blog/start-minecraft-server)

[ Previous guide Shockbyte vs Apex vs BisectHosting: Which Host to Pick](https://www.zcraftstudios.com/blog/shockbyte-vs-apex-vs-bisecthosting)[ Next guide EssentialsX Permissions: Nodes, LuckPerms Setup and Examples](https://www.zcraftstudios.com/blog/essentialsx-permissions-guide-luckperms)

<script type="application/ld+json">{"@context":"https://schema.org","@type":"Organization","@id":"https://www.zcraftstudios.com/#organization","name":"ZCraft Studios","alternateName":["ZCS","ZCraft","ZCraftStudios"],"logo":{"@type":"ImageObject","url":"https://www.zcraftstudios.com/img/apple-touch-icon.png","width":180,"height":180},"url":"https://www.zcraftstudios.com","description":"ZCraft Studios (ZCS) creates Minecraft plugins, server configs and tools. Browse resources, compatibility details and setup guides.","email":"Support@zcraftstudios.com","slogan":"Minecraft resources, configurations and custom server development.","knowsAbout":["Minecraft plugins","Minecraft server configuration","Java plugin development","Minecraft server optimization"],"sameAs":["https://dsc.gg/zcraftstudios","https://x.com/ZCraftNetwork","https://www.youtube.com/@zcraft_studios","https://www.instagram.com/ZCraftStudios"],"contactPoint":[{"@type":"ContactPoint","contactType":"customer support","email":"Support@zcraftstudios.com","availableLanguage":["English"],"areaServed":"Worldwide"}]}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","@id":"https://www.zcraftstudios.com/#website","url":"https://www.zcraftstudios.com","name":"ZCraft Studios","alternateName":["ZCS","ZCraft"],"description":"ZCraft Studios (ZCS) creates Minecraft plugins, server configs and tools. Browse resources, compatibility details and setup guides.","inLanguage":"en","publisher":{"@type":"Organization","@id":"https://www.zcraftstudios.com/#organization","name":"ZCraft Studios","url":"https://www.zcraftstudios.com"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://www.zcraftstudios.com/products?q={search_term_string}"},"query-input":"required name=search_term_string"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://www.zcraftstudios.com/blog/zgc-minecraft-server-flags-guide#article","headline":"ZGC for Minecraft Servers: Flags, Java Versions, G1 Choice","url":"https://www.zcraftstudios.com/blog/zgc-minecraft-server-flags-guide","mainEntityOfPage":"https://www.zcraftstudios.com/blog/zgc-minecraft-server-flags-guide","isPartOf":{"@type":"WebSite","@id":"https://www.zcraftstudios.com/#website","name":"ZCraft Studios","url":"https://www.zcraftstudios.com"},"speakable":{"@type":"SpeakableSpecification","cssSelector":["h1","main"]},"description":"Should your Minecraft server use ZGC or G1 with Aikar's flags? Learn the flags for Java 21 and 25, the tradeoffs and how to test the change.","datePublished":"2026-10-27T04:59:13.441843+00:00","dateModified":"2026-10-27T04:59:29.068351+00:00","author":{"@type":"Organization","@id":"https://www.zcraftstudios.com/#organization","name":"ZCraft Studios","url":"https://www.zcraftstudios.com/about"},"publisher":{"@type":"Organization","@id":"https://www.zcraftstudios.com/#organization","name":"ZCraft Studios","url":"https://www.zcraftstudios.com","logo":{"@type":"ImageObject","url":"https://www.zcraftstudios.com/img/apple-touch-icon.png","width":180,"height":180}},"inLanguage":"en","image":"https://www.zcraftstudios.com/api/og/blog/zgc-minecraft-server-flags-guide?v=828yzg"}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://www.zcraftstudios.com/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https://www.zcraftstudios.com/blog"},{"@type":"ListItem","position":3,"name":"ZGC for Minecraft Servers: Flags, Java Versions, G1 Choice","item":"https://www.zcraftstudios.com/blog/zgc-minecraft-server-flags-guide"}]}</script>
