Skip to content
EndercloudKnowledge Base
TroubleshootingTroubleshooting & Performance

OutOfMemoryError: Java heap space on a Minecraft server

java.lang.OutOfMemoryError means the server needed more memory than it has. Find what is using it (too many chunks, entities, plugins or a big modpack) before you upgrade.

Updated 3 min read
Difficulty:
Beginner
Time:
10 minutes
On this page

If your server crashes or freezes with java.lang.OutOfMemoryError: Java heap space (or GC overhead limit exceeded), Minecraft has run out of the memory (RAM) your plan gives it. Something is using more memory than expected: too many loaded chunks, too many entities, a heavy plugin or mod, or a modpack that is simply bigger than your plan.

Why it happens

  • Large modpacks need much more memory than plugin servers. Many big packs need 8 GB or more.

  • Generating new chunks, especially with players flying with elytra or many players spread out.

  • High view distance: more loaded chunks per player.

  • Entity build-up: huge farms, item piles, thousands of mobs.

  • Extra worlds from multiworld plugins, each with its own loaded chunks.

  • A memory leak in a plugin or mod: memory slowly climbs for hours until the crash.

High memory use in the panel header is not a problem on its own. Java keeps memory reserved and cleans it up when needed, so a server showing 80–90% RAM can be perfectly healthy. It is only a problem if you get this error or the server freezes.

How to fix it

  1. Find the moment it runs out. Open Files → logs/latest.log and the crash-reports folder. Note what was happening: many players online, someone exploring, a restart after adding a mod. See How to read logs.

  2. Check memory with spark (built into Paper and Purpur; on other software install it first). Run spark health to see memory use, and spark heapsummary to see what is holding memory. A plugin or mod name near the top points to the cause. See spark guide.

  3. Lower view distance. In Properties, set view-distance to 6–8 and restart. See Optimise Paper and Purpur settings.

  4. Pregenerate the world. Use Chunky and set a world border so the server is not generating land during play.

  5. Update or remove the leaking plugin or mod. If memory climbs steadily until a crash, try removing recently added plugins or mods one at a time.

  6. Unload unused worlds. Delete or disable worlds nobody plays in.

  7. Schedule a daily restart with Schedules as a short-term fix while you look for a leak.

When to upgrade

If spark shows memory is used by normal things (players, chunks, your mods) and it still runs out, your plan is too small for what you run. Upgrade from the billing panel: open your service and click Upgrade Plan. You only pay the difference and your files stay. See How much RAM do I need? and How to upgrade your plan.

Don't add your own -Xmx or other memory flags. Memory is set for you based on your plan, and changing it can make the server crash or get stopped instead of fixing anything.

Other memory errors

  • GC overhead limit exceeded: same cause. Java is spending almost all its time cleaning memory. Fix it the same way.

  • unable to create native thread: not about RAM size. A plugin or mod is creating too many threads. Check recently added plugins, then open a ticket if you can't find it.

Frequently asked questions

Does more RAM always make the server faster?

No. Once there is enough memory, extra RAM does nothing for TPS. Lag is usually about CPU work, not memory. See How to fix server lag.

The server just stops with no error

If memory was full just before, the server may have been stopped for going over its limit. Follow the steps above. If you can't find a cause, open a ticket with the time it happened.

Get a Minecraft serverInstant setup · 24/7 support · DDoS protection

Was this article helpful?

Related articles

Join Our Discord

Connect with our community of gamers and developers

Get instant support, share experiences, and stay updated with the latest news

Join Discord