Java memory settings: why the server stops abruptly (exit code 137)
Causes of sudden exit code 137 stops in Minecraft servers, Java memory regions, and community-recommended memory flag settings.
Bu səhifədə
Minecraft & Game Servers bələdçiləri
1. Exit code 137 and causes of sudden stoppage#
The panel memory limit is a hard container limit. If the total memory of the Java process (heap, off-heap, metaspace, and thread stacks) exceeds this limit, the system terminates the server immediately, often leaving no error in the log, resulting in exit code 137. Setting -Xmx equal to the full panel memory leaves no room for Java's other memory regions, making it the most common cause of sudden stoppages. Furthermore, when -XX:MaxDirectMemorySize is not configured, Java allows direct (off-heap) memory to grow up to the heap size by default, allowing network buffers to push total usage over the limit. The -XX:+AlwaysPreTouch flag reserves memory at startup; with a heap equal to the limit, it can cause the server to terminate within its first few seconds.
2. Memory flag guidelines based on community estimates#
- Rough community rules for -Xmx: for servers up to 3 GB, leave about 800 MB free below the panel limit.
- Rough community rules for 4-8 GB servers recommend leaving about 1.2-1.5 GB free below the panel limit.
- Rough community rules for 10 GB and larger servers recommend allocating roughly 80% of the panel limit to -Xmx.
- Commonly suggested extra flags: -XX:MaxDirectMemorySize=256M (up to 3 GB), 512M (4-8 GB), and 1024M (10 GB and up); setting direct memory too low can cause OutOfMemoryError: Direct buffer memory.
- Community recommendation for metaspace: -XX:MaxMetaspaceSize=256M.
- To prevent an excessive number of network memory pools on machines with many CPU cores: -Dio.netty.allocator.numDirectArenas=2.
- The -XX:+AlwaysPreTouch flag reserves memory at startup; with a heap equal to the limit, it can terminate the server within the first few seconds.
3. Steps to configure memory settings#
Check the console and usage graph
Navigate to the Console tab in the panel. Inspect the live usage graph and logs around the stoppage to verify whether the server stopped without an error message with exit code 137.
Lower -Xmx below the panel limit
If your plan lets you change startup variables, lower -Xmx below the panel limit based on your server size to leave headroom for off-heap and metaspace regions; otherwise open a support ticket.
Add the direct memory limit
Add the -XX:MaxDirectMemorySize flag (such as 256M or 512M) and optionally -XX:MaxMetaspaceSize=256M to prevent network buffers from consuming unbounded memory.
Restart the server and monitor
Restart the server to apply the changes. Monitor the console graph to verify that total memory usage stays safely below the panel limit.
4. Memory troubleshooting and resolutions#
Problemlərin həlli
Server stops with no error (exit code 137)
Total Java process memory exceeded the hard container limit; the most common cause is setting -Xmx equal to the full panel memory
If your plan lets you change startup variables, lower -Xmx below the panel limit according to community guidelines; otherwise open a support ticket
OutOfMemoryError: Direct buffer memory error in the console
The direct memory limit (-XX:MaxDirectMemorySize) is set too low for server network traffic or player load
Gradually raise the direct memory limit (for example, from 256M to 512M) and use -Dio.netty.allocator.numDirectArenas=2 to limit unnecessary network arenas
Bu bələdçi faydalı oldu?
Rəy birbaşa bu bələdçini yeniləyən komandaya gedir.
Həll tapa bilmədiniz?
Paneldən dəstək komandamıza müraciət aça bilərsiniz.

