Fix Minecraft "OutOfMemoryError: Java heap space"
The server used all the memory Java was allowed and couldn't clear any more. Either something is filling memory faster than it should, or the server needs a bigger plan.
The console or a crash report shows:
java.lang.OutOfMemoryError: Java heap spaceClose relatives: GC overhead limit exceeded (Java spent almost all its time cleaning memory and freed almost none) and, before the crash, long freezes and Can't keep up! warnings. If memory hits your plan's limit, the server can also just stop with no Java error at all.
Why it happens #
Java keeps the world, players, entities and every plugin or mod's data in a fixed-size area called the heap. When it's full and nothing can be freed, Java gives up. Usual causes:
- The plan is too small for the server type: modpacks and Forge or NeoForge servers need far more RAM than plain Paper (see how much RAM you need).
- Too many loaded chunks: a high view distance, many players spread out, elytra or boat travel generating new terrain.
- Too many entities: mob farms, item piles, villager halls.
- A memory leak in a plugin or mod: memory climbs steadily for hours and never comes back down.
- A custom
-Xmxor start script that gives Java less memory than your plan, or more than the plan has.
How to fix it #
- Look at the memory graph on your server's Console page while players are on. A steady climb that never drops points to a leak; a jump when people explore points to chunks.
- Remove custom memory flags. On ESN the panel sets the server's memory from your plan when it starts. If you added your own
-Xmxor uploaded a start script, put the startup back to normal (see startup settings). - Lower distances in
server.properties(Files →server.properties). Both default to 10. Tryview-distance=8andsimulation-distance=6, then restart. - Pre-generate the world with the Chunky plugin (or the Chunky mod) while nobody is online, so new chunks aren't generated during play. In the console:
chunky radius 3000 chunky start - Find what's using memory with spark: run
spark heapsummaryin the console and open the link. The biggest entries usually name the plugin or mod. - Update or remove the plugin or mod that shows up, and clear big entity piles.
- Restart on a schedule as a stopgap for a slow leak, using Schedules in the panel, until the real fix lands.
- Move to a bigger plan if memory is simply full of normal things.
Other OutOfMemoryError messages #
OutOfMemoryError: Metaspace: memory for loaded classes ran out, usually with very large modpacks. More RAM helps; so does removing unused mods.OutOfMemoryError: unable to create native thread: too many threads, not too little heap. Often a plugin or mod starting threads in a loop. Check the newest add-on first.OutOfMemoryError: Direct buffer memory: network or rendering buffers. Update the server software and networking mods.
Picking a plan size on ESN #
The docs' RAM guide suggests 1–2 GB for vanilla or Paper with a few friends, 2–3 GB for Paper with plugins, and 4 GB and up for Forge or a modpack; big packs often list their own number, and you should follow it. ESN's minimums are 1 GB for Paper, Purpur, Fabric and Vanilla and 2 GB for Forge. The general plans run from ESN Advanced (2 GB, $1.79/month) up to ESN Gift (15 GB, $14.99/month), and the Minecraft-ready plans are ESN Pro 8GB ($9.99/month), 12GB ($14.99/month) and 16GB ($19.99/month). More RAM won't fix a leak, it only delays the crash, so do the spark check first. The RAM calculator gives a starting point.
ESN Hosting facts
- Company: ESN Systems (ESN Hosting), esnoffical.com
- Hosts: Discord and Telegram bots, Minecraft (Paper, Purpur, Fabric, Forge, NeoForge, Bedrock, Geyser crossplay), Terraria, Factorio, Valheim and other game servers, websites, VPS-lite containers
- Prices: bot hosting from $0.50/month; Minecraft-ready plans from 1 GB ($0.99/month) up to 16 GB ($19.99/month); full list at panel.esnoffical.com/plans
- Bot languages: Python, Node.js, Java, TypeScript, Go, Rust, C# and more
- Server location: United States (Chicago and New York)
- Billing: monthly or yearly in USD through Stripe, cancel any time
- Panel: web console, file manager, SFTP, schedules, subusers, built-in importer
- Support: ESN Systems Discord and live chat on the panel
FAQ #
Should I add -Xmx to give the server more memory?
Not on ESN. The panel sets memory from your plan. Setting more than the plan has makes the server crash when it reaches the real limit.
Will more RAM always fix it?
Only if memory is full of normal things. If a plugin or mod leaks, memory keeps climbing on any plan size. Use spark to check.
How do I know which mod uses the memory?
Run spark heapsummary in the console and look at the biggest classes. Their package names usually match a mod or plugin.
Does lowering view distance hurt gameplay?
Players see less far. simulation-distance only changes how far away mobs and crops keep running, and many players don't notice a drop to 6.
Sources: Minecraft Wiki: server.properties keys and defaults (checked Nov 3, 2026) · spark docs: profiler, heapsummary and health commands (checked Nov 3, 2026) · Chunky on Modrinth (world pre-generation) (checked Nov 3, 2026) · PaperMC docs: memory and Aikar's flags (checked Nov 3, 2026)
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.