Two kinds of out-of-memory
java.lang.OutOfMemoryError: Java heap space means Java used all the heap you gave it with -Xmx. The fix is a larger heap or less memory use.
If the server disappears with no Java error, or the panel reports it was killed for exceeding memory, Java asked for more than the machine or container allows. The heap was set too close to the limit. The fix is a smaller -Xmx, leaving room for Java's other memory.
Set the heap correctly
Leave around 1 to 1.5 GB between -Xmx and the total memory available, more on large modpacks. On a hosted server, the panel normally sets this from your plan; avoid overriding it with a bigger number.
Find what uses memory
Run spark heapsummary to see which objects fill the heap. Steady growth over hours that a restart resets points at a leak in a plugin or mod. Big jumps when players explore point at chunk loading. A modpack that needs more than you have will run near its limit from the moment it starts.
- Lower view and simulation distance
- Pre-generate terrain and set a world border
- Remove or update the plugin or mod that leaks
- Schedule a daily restart while you investigate
When to upgrade
If the server sits near its memory limit under normal load with sensible settings, it simply needs more. Modpacks are the usual case. On StormNodes, moving to a larger plan keeps your files and world as they are.