Direct answer

First confirm the crash really says java.lang.OutOfMemoryError or otherwise identifies memory exhaustion. Then compare -Xmx with the machine/container memory limit. Increase heap only if the host has safe headroom; otherwise reduce the workload or investigate what is retaining memory.

Do not allocate every gigabyte to Xmx

The JVM uses memory outside the Java heap and the operating system also needs RAM. Paper specifically warns that container/panel limits too close to -Xmx can cause process kills. Leave headroom rather than setting Xmx equal to the host limit.

High usage alone is not a leak

Paper notes that the JVM normally grows the heap and may keep memory reserved instead of returning it to the OS. A panel showing “high RAM usage” is not by itself an out-of-memory failure. Look for actual OOM errors, bad GC pauses, or a usage pattern that keeps climbing under the same workload.

If memory keeps growing

  • Update Paper and affected plugins/mods.
  • Use a profiler/heap-oriented diagnostic appropriate to your environment.
  • Reproduce with suspect plugins/mods removed on a copy of the server.
  • Check large caches, map renderers, world tools, or modpack-specific systems if the growth correlates with them.

After a memory crash

Verify the world starts cleanly, inspect the crash/latest logs, and make a fresh backup after stability returns. Do not assume the last stack-trace line is the original memory consumer; OOM can surface where the next allocation happened.

Identify the kind of memory exhaustion
  1. A Java heap OutOfMemoryError, a native allocation failure and Linux exit code 137 are different evidence. Capture the exact log line and panel/container exit reason.
  2. Check -Xmx plus container memory headroom before increasing it; Java threads, network buffers and native libraries also consume RAM.
  3. If used heap keeps growing after GC under a repeatable workload, investigate with heap/profiling tools on a staging server instead of treating scheduled restarts as a fix.

Official references

These references were checked while preparing this fix. Version-specific behavior can change, so use the project documentation for your exact release when a detail differs.

Was this article helpful?
Help us improve this article

Tell us what is missing, unclear, outdated, or incorrect. You can also suggest something we should add.

What could we improve?
Do not include passwords, server IPs, or other private information.0 / 1000