← All guides
FreaksMC Guides

Minecraft Server Crashing With OutOfMemoryError? How to Fix It

Updated October 7, 2026 · 5 min read

If your Minecraft server keeps dying with java.lang.OutOfMemoryError in the console, or it just vanishes with no error at all, you're looking for the actual cause and a fix that sticks. "Add more RAM" is sometimes the answer, but often it isn't. Here's how to tell which kind of memory problem you have and what to do about each one.

Short answer
An OutOfMemoryError means the Java heap (set by -Xmx) filled up. A server that dies silently with exit code 137 means the container ran out, usually because -Xmx was set too close to the plan's total RAM. Leave 10-15% headroom outside the heap, check for leaky mods or runaway chunk loading, and only add RAM once you've confirmed the heap is genuinely too small for your modpack.

First, figure out which "out of memory" you have

There are really two different failures, and they need opposite fixes.

1. Java heap exhaustion

The console or crash report shows one of these:

This means Java used everything -Xmx allowed and couldn't free enough. The heap is too small for the load, or something is leaking memory.

2. Container or system memory exhaustion

The server just stops. No Java stack trace, maybe a line like exit code 137 or "killed" in the panel. That's the operating system's OOM killer ending the process because the whole process used more than the server is allowed, not just the heap.

Java uses memory outside the heap too: metaspace (class data, which is big in modded packs), thread stacks, the JIT compiler, and native buffers for networking and chunk I/O. On a big modpack that can easily be 1-2 GB on top of -Xmx.

3. The rarer ones

Possible causes -> fixes

-Xmx set too high -> leave headroom

The most common silent crash: an 8 GB plan with -Xmx8G. The heap alone can use all 8 GB, then metaspace and native memory push it over and the container kills it.

Fix: set -Xmx to roughly 85-90% of the server's total memory. On 8 GB, use around -Xmx7G. On heavy modpacks with hundreds of mods, leave a bit more. Setting -Xms equal to -Xmx is fine and avoids resize pauses.

-Xmx set too low -> raise it (within reason)

If you see Java heap space within minutes of startup, or during world load, the heap is just too small. A vanilla or Paper server is happy on 2-4 GB, but a big kitchen-sink pack can need 8-10 GB before anyone even logs in. In our own boot test, All The Mods 9 peaked at about 9.3 GB with nobody online.

Fix: raise -Xmx in steps of 1-2 GB and watch whether usage levels off. If it keeps climbing no matter what, it's probably a leak, not a size problem.

A mod is leaking memory -> find it and update or remove it

Signs of a leak: memory climbs steadily for hours, never drops after garbage collection, and the crash comes at roughly the same uptime each time.

Fix:

  1. Install spark (it's a mod for Forge, NeoForge and Fabric, and a plugin for Paper).
  2. Run /spark heapsummary once the server has been up a while. It lists which classes are holding the most memory, and class names usually include the mod's package name.
  3. Update that mod first. Leaks get fixed in patches all the time.
  4. If there's no fix, remove the mod or ask the pack author.

For deeper digging, -XX:+HeapDumpOnOutOfMemoryError makes Java write a .hprof file on crash that Eclipse MAT can open.

Too many chunks loaded -> cap view distance and chunk loaders

Each loaded chunk costs memory, and modded chunks (machines, inventories, entities) cost a lot more.

Fix:

  1. In server.properties, drop view-distance to 6-8 and simulation-distance to 4-6.
  2. Check for chunk loader blocks or FTB Chunks force-loaded claims. Limit how many each player can have.
  3. Look for farms with thousands of item entities or mobs. /spark profiler will point you at hot chunks.
  4. Pre-generate the world so exploration doesn't generate fresh terrain on the fly.

Bad or outdated GC flags -> use sane defaults

Old guides tell you to use -XX:+UseConcMarkSweepGC, which was removed in Java 14 and will stop the server starting on modern Java. Others pile on flags that fight each other.

Fix: on Java 17 or newer, G1 is the default and works well. If you want tuned flags, Aikar's flags are still a solid baseline for servers:

-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:InitiatingHeapOccupancyPercent=15

Note that -XX:+AlwaysPreTouch claims the full heap at startup, which makes the headroom rule above even more important.

When it's actually time to add RAM

Add memory when all of these are true:

At that point the pack simply needs more, and more heap will fix it. Remember to raise -Xmx along with the plan, keeping that 10-15% buffer.

How FreaksMC handles this

On FreaksMC the panel sets the heap based on your plan so you're not guessing at -Xmx, and it auto-picks the right Java version (8, 17, 21 or 25) for your Minecraft version. You also get a live console, a file manager for crash reports, and backup slots. If a modpack needs more room, the Extra RAM add-on lets you bump memory without changing plans, and a real human (the founder, usually) will help you read the crash log.

If you're tired of your server falling over, plans start at $3/mo and modpack plans run $14-36/mo, with a 24-hour money-back guarantee on first-time purchases. We'll even install your modpack for free. See plans and pricing.

Want a server that just runs fast?

FreaksMC runs on NVMe hardware with performance-tuned defaults baked in - pre-optimized Paper, sane view distances, and one-click world pre-generation. Set up in 60 seconds.

See plans from $3/mo

We use cookies for analytics & ads to measure how our site performs. Essential cookies always run. See our Privacy Policy.