Minecraft server out of memory: how to tell, and what to do
A Minecraft server that runs out of memory doesn't always say so. Sometimes you get a clear error. Other times it just gets slower and slower, then disappears. This page helps you work out which one you're dealing with.
How it shows up
- A clear error. The console prints
java.lang.OutOfMemoryError: Java heap space. Easy: the server told you. - A silent stop. The server goes offline with no error at all. When the whole process exceeds its memory limit, it gets killed from outside, so Minecraft never has a chance to write a message.
- Growing lag. Fine after a restart, worse every hour, with
Can't keep up!warnings creeping in. That's often memory pressure making the game spend its time cleaning up instead of running.
Is it really memory?
High usage on its own isn't a problem. Java is happy to use the memory it's given, so a graph that sits near the limit can be completely normal.
What you want to look at is the shape over time:
- Healthy: a sawtooth. Memory climbs, drops sharply when Java cleans up, climbs again.
- Trouble: the low points keep rising and never come back down. Something is holding on to memory it should have released, which is a leak.
Watch the memory graph on your server page for an hour or two of normal play before you decide.
Fixes, cheapest first
- Lower the view distance. In server.properties, drop
view-distancefrom 10 to 8 or 6, and setsimulation-distanceto 6. This is the single biggest saving on busy servers. - Remove what you don't use. Every plugin costs a little. Old ones that you've forgotten about add up, and some are the leak.
- Pre-generate your world. Generating new terrain as players explore is expensive. A world-border plus a pre-generation plugin moves that cost to a quiet time.
- Limit entities. Huge mob farms and thousands of dropped items cost memory and CPU. Most plugin servers have settings to cap mobs per chunk.
- Update. Memory leaks in plugins and mods are fixed regularly, so an outdated one is a common cause.
- Move up a plan. If your server is healthy and simply too small for its player count or modpack, that's what the extra RAM is for. It's a fix, not a failure.
Finding the culprit with spark
If memory keeps rising, install the spark plugin or mod. It's free and widely used:
/spark healthreportgives a quick overview of memory, CPU and tick speed./spark heapsummarylists which kinds of objects are using the most memory, which often points straight at a plugin.
For lag that isn't tied to memory, see How to fix server lag. If the server won't start at all, go to My server crashes or won't start.
Related guide: How to host a Minecraft server: home, VPS or managed hosting compared covers the full decision, from choosing a hosting route to a first-30-minutes checklist.
Still stuck? Open a ticket on Discord - run /ticket in any channel, pick a department, and include your Server ID or Invoice ID so we can jump straight in.