Skip to content

Minecraft JVM Arguments & Best GC Settings

Minecraft (Java Edition) is a JVM application — every tick of your world runs on the Java Virtual Machine, and the #1 cause of server lag spikes is garbage collection. Choosing the right JVM arguments can be the difference between a smooth 20 TPS and constant rubber-banding.

Why the default settings hurt

The vanilla launcher and many server hosts start the JVM with modest heap sizes and, historically, no explicit collector. Minecraft allocates a lot of short-lived objects (block updates, entities, packets). With a small heap:

  1. The young generation fills up every few seconds → frequent GC pauses.
  2. Every pause = the server freezes = players see lag spikes.
  3. On modded servers, thousands of classes also stress the metaspace.

How much RAM? (-Xmx / -Xms)

Give the JVM enough heap, and set initial = max so it never resizes mid-game:

SetupRecommended -Xmx
Vanilla client, normal render distance2–4 GB
Modded client (light–medium modpack)4–6 GB
Vanilla server (10 players)4–8 GB
Modded server (100+ mods)6–12 GB
-Xms4G -Xmx4G

More RAM is not always better

An oversized heap makes each Full GC sweep much more memory → longer pauses. Give the JVM what it needs, not everything you have.

Use a modern garbage collector

The single most impactful argument: replace the default collector with G1GC tuned for Minecraft's allocation pattern. The community-standard approach (popularized as "Aikar's flags" for Paper servers) follows these principles:

  1. G1GC with a small pause goal — pauses of a few ms instead of hundreds.
  2. Larger young generation (-XX:G1NewSizePercent=40) — Minecraft's objects die extremely young; a bigger Eden means fewer collections.
  3. Aggressive mixed collection (-XX:MaxGCPauseMillis=130, raised initiating occupancy) — reclaim old space before a Full GC is forced.
  4. Metaspace headroom for modded setups (-XX:MaxMetaspaceSize=256M).

A minimal modern starting point for a server:

bash
java -Xms4G -Xmx4G \
  -XX:+UseG1GC -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 \
  -XX:MaxGCPauseMillis=130 -XX:InitiatingHeapOccupancyPercent=30 \
  -XX:MaxMetaspaceSize=256M -jar server.jar nogui

Paper/Purpur servers ship with sensible defaults built in — but the GC settings above still apply when you tune further.

Then measure, don't guess

Add GC logging to your startup (one line), let the server run through a normal session, and look at the actual pauses:

bash
# add to the startup command (Java 9+)
-Xlog:gc*:file=gc.log:time,uptime

Then drop gc.log into the GC Log Analyzer: you will see exactly how long each pause is, how often they happen, and whether the heap is big enough. If the report shows frequent long pauses or a climbing after-GC line, raise -Xmx or apply the G1 flags above — then re-analyze to confirm.

Typical result

A modded server we tested went from 8-15 s of GC time per minute with default settings to sub-second total GC per minute with G1 + right-sized heap — lag spikes gone.