Prism Wiki
Troubleshooting

How to Fix a Minecraft Server Out of Memory Error

Diagnose and fix java.lang.OutOfMemoryError on a Minecraft server by adjusting memory, flags, and the real cause behind it.

Updated Jun 22, 20263 min readBy Prism Team

Few messages are as alarming as a server crash that ends with java.lang.OutOfMemoryError. The good news is that it has a small set of causes, and most are fixable. Here is how to diagnose and resolve it.

What the error means#

Java runs your server inside a memory space called the heap. When the heap fills up and the garbage collector cannot free enough room, Java throws an out of memory error and the server stops. So the question is always one of two things: is the server too small, or is something using far more memory than it should?

Step 1: Read the crash report#

The crash log usually points at the cause. Open the latest log and look for the lines just before the error. They often name a plugin, a mod, or an action like loading a huge number of chunks. That context tells you whether to add memory or hunt a leak.

Step 2: Check your current allocation#

Look at your start command and confirm how much memory the server actually gets:

java -Xms4G -Xmx4G -jar server.jar nogui

-Xmx is the ceiling. If it is set low for what you run, the server is simply undersized. Compare your value against our guide on how much RAM a Minecraft server needs.

Step 3: Add memory only if you are genuinely small#

If you run a modpack on 2 GB, the fix is more memory. Raise -Xmx to a sensible figure for your server type, but always leave headroom for the operating system. Do not assign every gigabyte the machine has.

A word of caution: if memory use was fine for weeks and then spiked, more RAM only delays the next crash. Find the real cause first.

Step 4: Look for the real cause#

A sudden out of memory error often comes from something specific:

  • A plugin or mod leak. Memory climbs steadily and never drops. Update the suspect or remove it and watch again.
  • View distance set too high. Each step up loads many more chunks. Lower view-distance and simulation-distance in server.properties.
  • Chunk loading abuse. A player or farm loading distant chunks can balloon memory. Tools like a chunk loader limit help.
  • Huge entity counts. Massive mob farms or dropped item piles eat memory. Cap them with plugin settings.

Step 5: Tune garbage collection#

Large heaps need good garbage collection settings or they pause and crash under pressure. Aikar's flags are a tuned set of JVM options designed for Minecraft. Applying them smooths memory handling. Managed hosts apply tuned flags automatically per server type, so you do not have to assemble them by hand.

Step 6: Confirm the fix#

After a change, watch memory over a full play session. Healthy memory rises and falls as the garbage collector does its job. Memory that only ever climbs means the leak is still present.

When to stop fighting it#

If you have right sized memory, tuned flags, and a clean plugin list and still hit the ceiling, the hardware may be the limit. Prism Nodes runs servers on fast Ryzen 9 hardware with tuned flags applied for you, which removes most memory headaches before they start. Use code IMSWITCHING for 15% off your first month.

Frequently asked questions

What does OutOfMemoryError actually mean?

The Java heap filled up and could not free enough space. Either the server needs more memory, or something is using far more than it should.

Should I just add more RAM?

Add memory if you are genuinely undersized, but a sudden spike often points to a plugin leak, huge view distance, or chunk loading issue worth fixing first.