PerlandFailure catalogue

Java ran out of memory and the server stopped

Fatalout_of_memory

The Java process of a Minecraft server or proxy filled the memory it is allowed, threw OutOfMemoryError and could not go on.

What the log shows

Written example6 lines
[19:42:17] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 6120ms or 122 ticks behind
[19:43:02] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
    at net.minecraft.world.level.chunk.storage.RegionFile.write(RegionFile.java:268)
[19:43:02] [Server thread/ERROR]: This crash report has been saved to: /data/./crash-reports/crash-2026-11-04_19.43.02-server.txt

Your log will have other names, versions and times. Search a line of it from all failures.

What it means

Java runs the server inside a fixed amount of memory. Most of it is the heap, where the game keeps loaded chunks, entities, players and everything plugins and mods store. The heap has a maximum, set with -Xmx (or the MEMORY setting of the itzg/minecraft-server image). When the server needs more than that maximum and the garbage collector cannot free enough, Java throws java.lang.OutOfMemoryError and the server stops.

The error names what ran out:

  • Java heap space or GC overhead limit exceeded: the heap is full.
  • Metaspace: Java has no room left for the code it loads, which grows with the number of plugins and mods.
  • unable to create native thread or Direct buffer memory: memory outside the heap ran out, or the system refused Java more threads.

Why it happens

  • The heap is too small for what the server runs. Large modpacks, many plugins, a high view distance or many players need more memory than the server was given.
  • Something keeps memory it never releases. A plugin or mod with a memory leak grows until the heap is full, often after hours or days of uptime.
  • A burst of work. Pre-generating the world, a large WorldEdit operation or a farm that spawns thousands of entities can fill the heap at once.
  • The heap is set larger than the container allows. Then the container is usually killed from outside instead (see container_oom_killed), or the memory outside the heap runs out first.

How to fix

  1. Give the server more memory, then start it again. In Docker, raise the container’s memory limit together with MEMORY (or -Xmx), and leave room between them: the heap is not all the memory Java uses.
  2. If it comes back after the server has run for a while, look at what was added last. Remove or update that plugin or mod and watch whether memory keeps growing.
  3. Lower the load: a shorter view-distance and simulation-distance in server.properties, fewer entities and loaded chunks, and world pre-generation in small steps.
  4. Metaspace: the cause is the amount of code loaded. Remove plugins or mods you do not use, or give the server more memory.
  5. Keep the crash report from the crash-reports folder: it shows what the server was doing when memory ran out.

In Perland

The issue appears in the server’s Diagnosis tab, with a link to the server’s resources, where you can give it more memory. Perland sets the Java heap from the container’s memory limit and keeps the rest (the larger of 512 MB and 15% of the limit) for the memory Java uses outside the heap, so raising the server’s RAM raises the heap too. Perland also measures heap use from inside Java, separately from the container’s memory, which tells whether the game itself filled its heap.

References

Details the diagnosis reports

Perland's server diagnosis returns this failure as the code out_of_memory with these parameters, each present only when the log names it.

ParameterMeaning
kindWhich memory ran out, read from the error's text - heap (the Java heap, where the game keeps the world, players and entities), metaspace (the room for loaded code), or other (any other kind, such as native threads, direct buffers or the garbage collector giving up).

Log lines this page covers

  • java.lang.OutOfMemoryError: Java heap space
  • java.lang.OutOfMemoryError: Metaspace
  • java.lang.OutOfMemoryError: GC overhead limit exceeded
  • java.lang.OutOfMemoryError: unable to create native thread
  • java.lang.OutOfMemoryError: Direct buffer memory