EN · $ USD
Minecraft Server Guides

How to Fix Minecraft OutOfMemoryError

7 min read Updated: OyunBulut technical team

In short

A Minecraft out of memory error means the Java heap is full and the garbage collector can't free up space. The cause is one of four things: a wrong Xmx value, a plugin or mod that leaks memory, too many loaded chunks and entities, or a server that genuinely doesn't have enough RAM. Read the error line first, then measure heap usage with spark to tell which one it is.

In this guide
  1. Read the error message correctly
  2. Cause 1: Xmx is set wrong
  3. Cause 2: A plugin or mod leaking memory
  4. Cause 3: Too many loaded chunks and entities
  5. Cause 4: Genuinely not enough RAM
  6. Permanent measures to prevent OOM
  7. Quick checklist
  8. Next step: move to a plan with enough memory

A Minecraft out of memory error means the server has completely filled the memory allocated to Java (the heap) and the Garbage Collector can't free any space. The server freezes, then crashes or shuts down. The fix isn't always "more RAM": the cause can be a wrong startup parameter, a plugin that leaks memory or chunks that are kept loaded for no reason. This guide walks you step by step through telling the four possible causes apart and calculating how much RAM you really need.

Read the error message correctly

The line you see in the console or in logs/latest.log largely tells you what kind of problem you have:

Error lineWhat it meansWhere to look first
java.lang.OutOfMemoryError: Java heap spaceThe heap is full, no room for new objectsXmx value, plugins, chunk count
java.lang.OutOfMemoryError: GC overhead limit exceededThe server spends most of its time collecting garbage but recovers very little memoryA memory leak or a heap running at its limit
java.lang.OutOfMemoryError: MetaspaceThe space reserved for class definitions is fullLots of mods, frequently reloading plugins
unable to create native threadThe operating system won't allow new threadsA plugin leaking threads, process limits
No error, the server suddenly gets "killed"The operating system terminated the process for exceeding memoryXmx set too close to your plan's RAM

The last row is especially important: if there's no Java error and the server quietly shuts down, the problem usually isn't the heap but the Java process's total memory use exceeding your plan's limit.

Cause 1: Xmx is set wrong

The -Xms (initial) and -Xmx (maximum) parameters tell Java how much heap it can use. There are two typical mistakes:

  • Xmx too low: Even if your plan has 8 GB, if the startup command says -Xmx2G the server only uses 2 GB and throws OutOfMemoryError early.
  • Xmx equal to the plan limit: Java also uses memory outside the heap (Metaspace, thread stacks, network buffers, native libraries). If you set Xmx to your plan's full RAM, total usage goes over the limit and the operating system kills the process.

As a rule of thumb, give the heap about 85-90 percent of your plan's RAM and leave the rest for Java's off-heap needs. For example, for a 12 GB plan:

java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+HeapDumpOnOutOfMemoryError -jar server.jar --nogui

Keeping Xms and Xmx equal stops the heap from constantly growing and shrinking. Game panels often set these values automatically based on your plan's RAM; it's still worth checking the startup parameters. For the full optimized flag set, see our guide on Minecraft JVM tuning with Aikar's Flags.

Cause 2: A plugin or mod leaking memory

A leak has a clear signature: memory is normal right after the server starts, climbs steadily over hours and doesn't come back down even when the player count drops. Eventually it crashes with GC overhead limit exceeded or Java heap space. Typical causes:

  • Plugins that cache player data and never clear it
  • Old versions of hologram, NPC or scoreboard plugins
  • Frequent use of the /reload command (old classes can stay in memory)
  • Incompatible mod versions in modpacks

Measure with spark

The spark plugin (available for Paper, Fabric and Forge) shows what's filling up the heap:

/spark health
/spark gc
/spark heapsummary

The /spark heapsummary output shows which classes hold the most memory. The package name in the class name (for example com.ornek.hologram) usually points straight at the culprit plugin. For deeper analysis, a file taken with /spark heapdump can be inspected with tools like Eclipse MAT. For detailed usage, check out our guide on finding TPS drops with spark.

Confirm the suspect plugin

  1. Back up the server.
  2. Temporarily remove the suspect plugin from the plugins folder.
  3. Run the server for a few hours with the same player load and compare the memory graph.
  4. If the problem is gone, try the plugin's latest version or switch to an alternative.

Cause 3: Too many loaded chunks and entities

Every loaded chunk and the entities inside it (mobs, items, minecarts, item frames) take up space on the heap. If memory grows not with the player count but with how spread out players are across the world and the farms they build, this is most likely the cause.

  • view-distance: Lowering this value in server.properties cuts the number of loaded chunks quadratically. On busy servers, 6-8 is a common choice; you can also keep simulation-distance lower separately.
  • Chunk loaders: Areas kept permanently loaded (chunk loader mods, spawn chunks, ender pearl tricks) tie up memory permanently.
  • Entity buildup: Farms with thousands of animals and items piling up on the ground eat both RAM and TPS. /spark profiler and Paper's entity limit settings help here.
  • World generation: Players quickly exploring new areas cause sudden memory and CPU spikes. Pre-generating the world moves that load outside play hours; see pre-generating your world with Chunky.

Cause 4: Genuinely not enough RAM

If Xmx is right, there's no leak and chunk settings are reasonable but memory still maxes out at peak hours, your server has outgrown its plan. Use this method to estimate what you really need:

  1. Measure heap usage with /spark health at your busiest hour.
  2. Note the usage left after garbage collection (the floor value); the post-GC floor, not the momentary peak, is your real need.
  3. Add a 30-50 percent safety margin to that floor. The heap shouldn't sit close to full all the time if the garbage collector is to work comfortably.
  4. Add roughly another 10-15 percent to that heap value for off-heap usage. The result is the plan RAM you need.

Example: if the post-GC floor is 7 GB, you need 7 × 1.4 ≈ 10 GB of heap, plus off-heap headroom for roughly 11-12 GB of plan RAM. In that case the OB-MC-4 Minecraft server with 12 GB RAM is the right choice. If the floor comes out higher on heavy modpacks or plugin servers approaching around 50 players, the OB-MC-5 plan with 16 GB RAM and 6 CPUs leaves headroom on both memory and CPU.

Important: adding RAM doesn't fix a leak, it only delays the crash. Rule out Causes 1-3 first and make a RAM upgrade your last decision.

Permanent measures to prevent OOM

Fixing the error once isn't enough; make the server observable so it doesn't come back:

  • Keep heap dumps on: The -XX:+HeapDumpOnOutOfMemoryError flag in the startup command writes a copy of memory as a .hprof file at the moment of the crash. That file is the most reliable way to prove afterward which plugin caused the problem. It takes up as much space as the heap size; delete it once you've reviewed it.
  • Scheduled restarts: A daily restart at the hour with the fewest players limits the impact of slow leaks. It's not a fix, just a stopgap until you find the leak.
  • Don't update plugins in bulk: If you update plugins one at a time and watch the memory graph after each update, you'll find the source of a new leak right away.
  • Read the recommended RAM for modpacks: Modpack developers usually state a minimum server RAM. Servers set up below that value throw OOM as players join, even without a leak.
  • Use a current Java version: Use the Java version your Minecraft version requires; older Java versions lag behind in both GC efficiency and compatibility.

Along with these measures, reviewing the memory graph weekly helps you catch problems before players notice. A rising baseline is the clearest warning you'll get before a crash.

Quick checklist

  1. Identify the OutOfMemoryError type in the log.
  2. Compare the Xmx value in the startup command with your plan; it shouldn't exceed 85-90 percent of the plan.
  3. Watch whether server memory keeps rising over time.
  4. Inspect the classes holding the most memory with /spark heapsummary.
  5. Review your view-distance and simulation-distance values.
  6. Use a full restart instead of /reload.
  7. Measure the post-GC floor and calculate your real RAM needs.

Next step: move to a plan with enough memory

If your measurements show the server really needs more memory, it's time to upgrade. OyunBulut Minecraft servers come with NVMe SSD, DDoS protection and a web panel, and run in our Istanbul data center. Based on your measured value, start with the 12 GB OB-MC-4 or the 16 GB OB-MC-5, and compare all options on the Minecraft server plans page. If you're unsure which plan to pick, open a support ticket and share your spark output.

Frequently asked questions

How do I fix a Minecraft server running out of RAM?

First check whether the Xmx value in the startup command fits your plan's RAM. Then use spark to check for a memory-leaking plugin and look at the number of loaded chunks; only if those are clean should you move to a plan with more RAM.

Should I set Xmx to my plan's full RAM?

No. Java also uses memory outside the heap, so Xmx should be about 85-90 percent of your plan's RAM. Otherwise the process exceeds the total limit and can be killed by the operating system.

What does GC overhead limit exceeded mean?

It means Java spends most of its time collecting garbage but recovers very little memory. It's usually a sign of a memory leak or a heap that's constantly running at its limit.

How can I tell which plugin is filling up the RAM?

Install the spark plugin and run /spark heapsummary. In the output, the package names of the classes holding the most memory usually point to the plugin responsible.

Does lowering view-distance reduce RAM usage?

Yes. The number of loaded chunks grows with the square of the view distance, so lowering view-distance and simulation-distance noticeably reduces both RAM and CPU load.

For this guide

Recommended plans

If your measured post-GC memory floor still exceeds your current plan after fixing Xmx, plugins and chunk settings, the 12 GB OB-MC-4 or 16 GB OB-MC-5 gives you the memory headroom to leave no room for OutOfMemoryError.

OB-MC-4

Recommended

12 GB RAM

$9.24/mo

+VAT

  • Processor4 CPU
  • Disk60 GB NVMe
  • LocationIstanbul
  • DDoS Protection
  • Automatic Setup
  • Web Panel
  • 7/24 Support

16 GB RAM

$12.58/mo

+VAT

  • Processor6 CPU
  • Disk80 GB NVMe
  • LocationIstanbul
  • DDoS Protection
  • Automatic Setup
  • Web Panel
  • 7/24 Support

Minecraft — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.