Optimization ⏱️ ~9 min read

Memory & JVM Arguments Guide — The Technical Answer to Stutter in Large Modpacks

In big modpacks, "it freezes for a second out of nowhere" usually traces back to JVM garbage-collection pauses. Sizing your heap, applying Aikar's Flags (the G1GC tuning set), when ZGC — vanilla's new default in 2026 — is actually the better pick, matching Java versions, and which performance mods to pair.

📑 Contents (10 sections)
  1. Why Adding RAM Alone Isn't the Answer
  2. Step 1 — Sizing RAM Allocation
  3. Step 2 — Applying Aikar's Flags
  4. Step 3 — Allocating 12GB or More
  5. Step 4 — Matching the Java Version
  6. Step 5 — Performance Mods Worth Pairing
  7. Step 6 — What to Actually Measure
  8. Common Symptoms and What to Check
  9. Closing
  10. Related Reading

Why Adding RAM Alone Isn't the Answer

The recurring question about ATM10/DarkRPG-class packs is "I gave it 16GB, why does it still stutter?" A bigger heap also means more for the garbage collector to walk on each cycle. How the JVM manages that memory matters as much as how much you hand it.

This guide is the technical follow-up to the [Performance Optimization Guide](/en/guides/performance-optimization/), focused on JVM arguments.

Step 1 — Sizing RAM Allocation

Rough guidance by pack size

| Modpack size | Suggested allocation | Suggested PC RAM | |---|---|---| | Vanilla+ (10–30 mods) | 4–6 GB | 8 GB | | Medium (50–150 mods) | 6–8 GB | 16 GB | | Large (200+ mods) | 8–12 GB | 16 GB or more |

Principle: always leave the OS its share

On a 16GB PC, 8–10GB to the modpack is a sane range. Leave roughly 6GB for the OS, browser, and Discord. Once the system runs short, it starts swapping to disk and everything slows down regardless of what you allocated.

Where to set RAM

  • CurseForge app: Settings → Minecraft → Java Settings → allocated memory slider
  • Modrinth app: instance settings → Java → memory
  • Prism Launcher: right-click instance → Edit → Settings → Java → Memory
  • Step 2 — Applying Aikar's Flags

    What Aikar's Flags are

    Aikar's Flags is a published G1GC tuning set of JVM arguments from Aikar of the Paper server project. The core idea is to keep any single GC pause short by adjusting the Young Generation ratio and when concurrent marking starts. It's effectively the standard for Minecraft server hosting.

    The set was written for servers, and it's commonly pasted into clients (including singleplayer) as well. Actual benefit varies by machine and pack — compare stutter before and after and judge for yourself.

    The full argument set (copy-paste)

    -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true
    

    What the main flags do:

  • -XX:+UseG1GC — use the G1 garbage collector
  • -XX:MaxGCPauseMillis=200 — target a 200ms GC pause (a goal, not a guarantee)
  • -XX:+AlwaysPreTouch — commit heap pages at startup; slightly slower launch, steadier allocation afterwards
  • -XX:+DisableExplicitGC — ignore System.gc() calls from code (they force full pauses)
  • -XX:G1NewSizePercent / G1MaxNewSizePercent — Young Generation size range
  • -XX:InitiatingHeapOccupancyPercent — heap occupancy that triggers concurrent marking
  • The last two (-Dusing.aikars.flags, -Daikars.new.flags) are marker system properties and don't change behavior.

    Aikar's guidance also says to set -Xms equal to -Xmx (e.g. -Xms8G -Xmx8G).

    Where to enter them

  • CurseForge app: Settings → Minecraft → Java Settings → additional arguments field
  • Modrinth app: instance settings → Java → custom arguments
  • Prism Launcher: instance Edit → Settings → Java → JVM arguments
  • Step 3 — Allocating 12GB or More

    Aikar's documentation says to adjust these values when allocating 12GB+:

  • -XX:G1NewSizePercent=40 (up from 30)
  • -XX:G1MaxNewSizePercent=50 (up from 40)
  • -XX:G1ReservePercent=15 (down from 20)
  • -XX:InitiatingHeapOccupancyPercent=20 (up from 15)
  • The direction is the same: on a large heap, a bigger Young Generation means fewer collections.

    When to consider ZGC

    2026 added an option. Mojang switched vanilla's default collector from G1GC to ZGC starting with the 26.1 snapshots.

    That's the official launcher's default for vanilla, though — it is not a signal to stop using Aikar's Flags on modpacks. It depends on the case.

    | Situation | Recommendation | |---|---| | Modpack (1.20.1, 1.21.1 …) with 6–12GB | Aikar's Flags (G1GC) — Step 2 as written | | 26.x vanilla via the official launcher | Nothing to do — the launcher already uses ZGC | | Large modpack with 16GB+ allocated | Worth testing ZGC |

    On a large heap ZGC is strong at keeping pauses short. At 6–8GB, G1GC is often the more efficient choice, so switching isn't automatically an improvement. Measure before and after — if you can't feel a difference, switch back.

    ⚠️ ZGC and Aikar's Flags cannot be combined. Aikar's Flags are a bundle built around -XX:+UseG1GC and the -XX:G1... family. Moving to ZGC means deleting all of them and using the set below. Mixing the two gets the G1 options ignored, or a JVM warning.

    The ZGC flags differ by Java version. Getting this wrong stops the game from launching.

  • Java 21 (1.20.5–1.21.x packs) → -Xmx8G -Xms8G -XX:+UseZGC -XX:+ZGenerational
  • Java 24 and later (26.x) → -Xmx8G -Xms8G -XX:+UseZGC
  • Generational ZGC became the default in Java 23, which deprecated -XX:+ZGenerational, and Java 24 removed the flag entirely — passing it on 24+ does nothing. On Java 21, omitting it leaves you on the older non-generational ZGC.

    Step 4 — Matching the Java Version

    Required Java by Minecraft version

  • 26.1 and later → Java 25
  • 1.20.5 – 1.21.x → Java 21
  • 1.18 – 1.20.4 → Java 17
  • 1.17 → Java 16 or later
  • 1.16.5 and earlier → Java 8
  • Too low a version and the game won't start at all — you'll get UnsupportedClassVersionError. The G1GC flags above are standard HotSpot options (Adoptium, Zulu, Oracle), so they carry over unchanged between Java 17 and 21. Note that Minecraft 26.1 raised the minimum to Java 25, and that the official launcher defaults to ZGC in that band.

    What launchers handle for you

    The CurseForge and Modrinth apps fetch and use the Java runtime the pack asks for. Launchers that set Java per instance (Prism) need you to point at the right JDK yourself.

    Step 5 — Performance Mods Worth Pairing

    JVM flags only touch GC behavior. Cutting rendering cost and memory usage itself is the mods' job. Many packs already ship these — check your mods folder before adding duplicates.

  • [Embeddium](/en/mods/embeddium/) — a Forge/NeoForge rendering optimizer forked from Sodium's code, focused on terrain rendering. (On Fabric, use Sodium instead.)
  • [FerriteCore](/en/mods/ferritecore/) — deduplicates block state and model data to cut memory use. The author's published measurement on All of Fabric 3: 1,792MB → 984MB
  • [ModernFix](/en/mods/modernfix/) — an all-in-one patch mod that reduces boot time, world load time, and memory usage. Built to run alongside other performance mods
  • [Entity Culling](/en/mods/entity-culling/) — skips rendering entities and block entities you can't actually see. Client-side only; servers don't need it
  • Step 6 — What to Actually Measure

    The F3 debug screen

    Press F3 in-game: the right side shows FPS and memory used / allocated. If usage sits pinned against the allocation, GC is running often and there's room to raise the allocation. If there's plenty of headroom and it still stutters, the cause isn't memory — it's rendering or tick load.

    [Memory Usage Title](/en/mods/memory-usage-title/)

    A tiny mod that prints memory usage in the Minecraft window title bar. Useful when you want to watch the trend without keeping F3 open. It only displays — it doesn't free anything.

    Common Symptoms and What to Check

    "Memory has headroom but it freezes for a second periodically"

    GC pauses are the likely cause. Apply Aikar's Flags and set -Xms equal to -Xmx.

    "OutOfMemoryError during startup"

    Either the allocation is too small, or you're on 32-bit Java (which caps the heap severely). Confirm 64-bit Java, then raise the allocation.

    "FPS itself is low"

    JVM flags won't fix this. Look at render distance, graphics options, and rendering optimization mods — see the [Performance Optimization Guide](/en/guides/performance-optimization/).

    "Stutters when moving into new chunks"

    That's chunk generation plus disk I/O. Put the instance on an SSD and lower render/simulation distance first.

    Closing

    The order is simple: size the allocation sensibly (leave the OS its share) → add Aikar's Flags → match the Java version → check your performance mods. If it still stutters after that, it probably isn't GC — move on to diagnosing rendering and tick load.

    Related Reading

  • [Performance Optimization Guide](/en/guides/performance-optimization/) — optimization beyond the JVM
  • [Mod Conflict Troubleshooting](/en/guides/mod-conflict-troubleshooting/) — reading crash reports
  • [PC Spec-Based Modpack Picker](/en/info/pc-spec-modpack-guide/) — modpack picks by RAM/GPU
  • 📦 Related Modpacks