«java.lang.OutOfMemoryError: Java heap space»

Errors & Fixes Reviewed September 6, 2026 2 min read

Unlike most lag complaints, this one genuinely is about memory. The server asked for more than it had and stopped. The question worth answering is whether it needed it, or whether something was wasting it.

What you are seeing

  • java.lang.OutOfMemoryError: Java heap space in the console
  • The server stops abruptly, sometimes mid-save.
  • It happens after a period of uptime rather than at start.

Why it happens

Java runs inside a fixed memory ceiling. When live data fills it and collection cannot free enough, the process gives up. Either the workload legitimately needs more room, or something is holding memory it should have released.

What to do

  1. Note when it happens

    At startup means the plan is too small for what you are loading — a modpack that does not fit. After hours or days of running means something is accumulating.

  2. If it accumulates, find what

    /spark heapsummary lists what is occupying memory. A plugin near the top that keeps growing between runs is a leak, and the fix is updating or removing it.

  3. Reduce what has to stay loaded

    Lower view distance, fewer permanently loaded chunks and fewer entities all reduce the baseline the server has to hold.

  4. Upgrade if the workload is simply bigger

    A hundred-mod pack in 4 GB is not a leak, it is the wrong size. This is one of the two cases where more RAM is genuinely the answer.

How to confirm it worked

The server runs through a full day under normal load without the error, and /spark heapsummary shows headroom left at the end of it.

Worth knowing

A crash here can leave the world mid-write. If the server misbehaves after an out-of-memory stop, restore the most recent backup rather than playing on.