Benchmarking Java 21 Generational ZGC vs G1GC on 260+ Industrial Modpacks
1. Extreme Young-Generation Allocation in Modded Minecraft
Minecraft's voxel engine allocates millions of transient objects (BlockPos, Vec3, ItemStack, serialized NBT compounds) every second. On GregTech Borealis and CryoTech 1.20.4, young-generation allocation regularly hits 1.8–3.4 GB/sec. Under classic G1GC on heaps above 12 GB, mixed evacuation pauses spike to 45–110 ms — felt immediately as camera hitching or server tick jitter.
2. Why Generational ZGC (JEP 439) Eliminates Frame Stutters
Java 21's Generational ZGC (-XX:+UseZGC -XX:+ZGenerational) separates young ephemeral objects from long-lived chunk caches while performing relocation concurrently via colored pointers and load barriers:
- 99th Percentile Server GC Pause (32 GB Heap): dropped from 39.2 ms (G1GC) down to 0.11 ms (Generational ZGC).
- Smooth Client 1% Low FPS: flying across dense industrial bases at 30 chunks/sec produces zero GC frame spikes.
3. Reference Server & Client JVM Flags
IceLaunch v5.2.0 applies these flags automatically on 8+ GB systems, and we run the following profile across our Keflavík blades:
start-realm.sh (GraalVM 21 + Generational ZGC + Transparent HugePages)
java -Xms32G -Xmx32G \
-XX:+UseZGC -XX:+ZGenerational \
-XX:+AlwaysPreTouch -XX:+DisableExplicitGC \
-XX:+UseTransparentHugePages -XX:+PerfDisableSharedMem \
-Djava.security.egd=file:/dev/urandom \
@libraries/net/neoforged/neoforge/20.4.237/unix_args.txt nogui