Guidefor server owners3 min read
How much RAM does a Minecraft server need?
Player count matters less than you think, mods matter more, and giving the server every gigabyte you own makes it slower. What to allocate and why.
Start here
For most servers, these are right:
| Server | Allocate |
|---|---|
| Vanilla or Paper, up to 10 players | 2 to 4 GB |
| Paper, 10 to 40 players, some plugins | 6 to 8 GB |
| Paper, 40+ players, many plugins | 8 to 12 GB |
| Small modpack, up to 10 players | 6 to 8 GB |
| Large modpack, up to 10 players | 10 to 16 GB |
| Proxy (Velocity or BungeeCord) | 512 MB to 1 GB |
That last row surprises people. A proxy holds no world and simulates nothing. It moves packets. It does not need eight gigabytes and never has.
Why more is not better
Java is a garbage collected runtime. It does not free memory the moment something stops being used; it waits until it needs the space and then collects. The larger the heap, the more memory the collector has to walk when it runs, and the longer the pause while it does.
On a Minecraft server, a pause is a freeze. Everyone stops moving. So the goal is not "as much RAM as possible", it is "enough that the collector is not thrashing, and no more".
A server that runs smoothly on 6 GB is frequently worse on 16 GB, and the operator concludes they need 32.
What actually consumes memory
In rough order:
Loaded chunks. This is the big one. Every player loads a square of chunks around themselves, and each loaded chunk holds block data, block entities and everything in it. The square grows with the square of view distance, so going from view distance 10 to 20 does not double the memory, it roughly quadruples it.
Entities. Mob farms, item stacks on the ground, minecarts, armour stands. A server with a large automated farm can hold tens of thousands of entities.
Mods. Every mod loads classes, registers blocks and items, and often keeps its own world data. A hundred-mod pack uses several gigabytes before a single player joins.
Plugins. Much lighter than mods, but a plugin holding a large database in memory is a plugin holding a large database in memory.
Players. Least of all, per player. The chunks they load cost far more than they do.
Setting it
java -Xms6G -Xmx6G -jar server.jar nogui
-Xmxis the maximum heap.-Xmsis the starting heap. Set it equal to-Xmxon a server, so the heap is never resized while the game runs.
Leave headroom for the operating system. On an 8 GB machine, allocate 6 GB and not 8: the JVM uses memory outside the heap as well, and a machine that starts swapping is slower than a machine that is short on heap.
Reducing the need instead
Before allocating more, try spending less. These usually help more than an extra four gigabytes:
- Lower view distance. 8 to 10 is plenty for most servers. This is the single biggest lever.
- Set simulation distance lower than view distance. Players can see far without the game simulating that far.
- Cap entities. Every server platform has limits for mobs per chunk and item stacks on the ground.
- Set a world border. An unbounded world is unbounded chunk generation, and every chunk generated is a chunk stored forever.
- Trim the region files. A world explored for three years holds chunks nobody has visited since. Pruning unused regions shrinks the save and the memory needed to serve it.
How to tell you have it wrong
Too little: the log shows OutOfMemoryError, or the server freezes for seconds at a
time under load, or it dies during world generation.
Too much: memory use sits near the ceiling permanently and the server has occasional long freezes with no obvious cause, particularly on a large heap with default collector settings.
About right: memory rises and falls in a sawtooth as the collector runs, pauses are short enough that nobody mentions them, and tick time is steady.
If tick time is the actual problem rather than memory, fixing server lag covers what to measure and in what order.
Java version matters too
Newer Java versions ship better garbage collectors, and Minecraft has required newer Java with every recent release. Running the newest runtime your Minecraft version supports is usually a free improvement.
Check what your version needs with the Java version checker, and get verified builds from the Java pages with checksums straight from the publisher.