java.lang.OutOfMemoryError: Direct buffer memory
Java allocates some memory outside the heap: direct byte buffers used heavily by the network stack (Netty) and fast file I/O. When those run out, the JVM throws OutOfMemoryError: Direct buffer memory even though heap usage looks comfortable. More players connecting, chunk streaming and proxy setups all grow this pool.
Fastest path: paste your crash report into the Crash Doctor — it identifies this pattern and 40+ others automatically. No signup.
How to fix it
- 1
Raise MaxDirectMemorySize
Add -XX:MaxDirectMemorySize=1G (or higher for busy servers) to the JVM flags. By default it is tied to heap size, which starves it when the heap grows.
- 2
Keep heap below host RAM
Direct buffers live outside the heap, so heap + buffers must fit the container. A heap equal to host RAM leaves nothing for buffers — and invites exit code 137 instead.
- 3
Reduce connection churn
Rapid reconnects and huge join bursts allocate buffers fast. Connection throttling and a stable player count smooth the peaks.
- 4
Check proxy configurations
Velocity/BungeeCord chains buffer heavily on both hops. Both sides need headroom — a fix on the game server alone can leave the proxy starving.
Alternative causes
These can produce the same error message — worth ruling out if the steps above don't resolve it.
A mod leaking buffers
If the error arrives after days of uptime rather than at peaks, something holds buffers without releasing. A spark profile under the crash window identifies the allocator.
Frequently asked
Is this the same as heap OutOfMemoryError?
No — it is a separate, off-heap pool. Raising -Xmx can even make it worse by leaving less room for buffers.
Why during many players joining?
Every connection allocates buffers for the handshake and chunk transfer. A mass join spikes direct memory harder than steady-state play.
What value for MaxDirectMemorySize?
Start at 1G for small servers, 2G+ for busy or proxied ones — sized against the headroom left after your heap.
Want this auto-fixed on your server?
CoalHosting's Minecraft hosting runs the same pattern database against every crash and applies the known fix before your players notice. Free crash diagnosis works on any server, hosted or not.
Related crashes
java.lang.OutOfMemoryError: Java heap space
Fix Minecraft server OutOfMemoryError crashes — the JVM ran out of allocated heap. Most modpacks need 8–16 GB;…
java.lang.OutOfMemoryError: GC overhead limit exceeded
'GC overhead limit exceeded' is the slow-crash cousin of OutOfMemoryError — the JVM spends nearly all its time…
Server exited with code 137 (SIGKILL / OOM)
Exit code 137 means the OS killed the Java process — almost always host-level out-of-memory pressure, not a Mi…
Last reviewed 2026-09-06. If a step is wrong or out of date, tell us — we'll fix the article and the auto-pattern at the same time.