criticalJava ErrorsAffects: All versions
How to Fix Java Heap Space on Servers
Fix Java Heap Space on Minecraft servers by increasing -Xmx in the start script and optimizing garbage collection.
Quick Fix
Edit your server start script to increase -Xmx. Use at least 4GB for vanilla, 6-8GB for modded.
Error Message
java.lang.OutOfMemoryError: Java heap space (Server)How to Fix
1
Edit start.sh or start.bat to increase -Xmx (e.g., -Xmx8G)
2
Use G1GC: -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+ParallelRefProcEnabled
3
Limit view distance in server.properties (8-10 chunks)
4
Use Spark profiler to find memory leaks
5
Set a world border to limit loaded chunks
Common Causes
- Server start script allocates too little RAM
- Too many players or loaded chunks
- Plugin memory leak
- Pre-generation tools loading too many chunks at once
Diagnostic Steps
- Check current -Xmx in start script
- Increase to appropriate size for your player count and mods
- Add G1GC flags for better garbage collection
- Monitor memory with Spark
FAQ
How much RAM for a modded server?
6-8GB for a modded server with 10-20 players. Increase if using heavy modpacks. Never exceed your host's physical RAM.