How to Reduce Minecraft Server RAM Usage (Practical Fixes)
Your panel's memory graph sits at 95%, or worse, the server crashes with OutOfMemoryError when a few friends log on. Before you pay for a bigger plan, it's worth knowing what's actually filling that memory, because a lot of it is under your control. Here are the fixes that make a real difference, starting with the one that surprises most people.
-Xmx about 1 to 1.5 GB below your plan limit. Giving Java more than you need doesn't help.First: is your server really short on RAM?
Java manages memory in a big pool called the heap, sized by -Xmx. Java doesn't free memory back to the system the moment it's done with it. It keeps the heap and cleans it up in the background (garbage collection). If your startup flags set -Xms equal to -Xmx (which Aikar's flags recommend), the server claims the full heap at startup.
So a panel graph that says 7.6 of 8 GB doesn't mean the server is in trouble. To see what's really going on, use spark (built into Paper since 1.21; on Fabric, Forge and NeoForge install the spark mod):
/spark health show --memory
This prints TPS, CPU and memory usage, including how much of the heap is actually in use. If heap use climbs, drops after garbage collection and climbs again, that sawtooth is healthy.
You genuinely need to act if you see:
java.lang.OutOfMemoryErroror "Java heap space" in the console- The server getting killed with no Java error (the container hit its limit)
- Frequent stutters that line up with long garbage collection pauses
If that's you, read on. If not, your RAM is probably fine and lag is coming from somewhere else, likely CPU. See why your server is lagging.
1. Lower view distance and simulation distance
Loaded chunks are the biggest memory user on most servers, and every player loads a square of chunks around them. The two settings in server.properties that control it:
view-distance=10
simulation-distance=10
Both default to 10. view-distance controls how many chunks are sent to players, and simulation-distance controls how far away the world actually ticks (mobs move, crops grow). Because the area grows with the square of the distance, small changes add up. Going from 10 to 8 cuts the area by roughly a third.
Good starting points:
| Server | view-distance | simulation-distance |
|---|---|---|
| Small friends SMP | 8 to 10 | 6 to 8 |
| Busy plugin server | 6 to 8 | 4 to 6 |
| Heavy modpack | 6 to 8 | 4 to 6 |
Players with a mod like Distant Horizons or Bobby can still see far on their own screen, and lower simulation distance mostly affects far-away farms. More detail: view and simulation distance explained.
2. Cut down entities
Every mob, dropped item, arrow and XP orb is held in memory and processed every tick. Servers collect them quietly: animal pens nobody culls, mob farms with no kill chamber, item piles from overflowing hoppers.
- Find the hotspots. spark's profiler or a quick look around big farms usually finds them. Our guide to too many mobs dropping TPS shows how.
- Cap breeding. Set a rule like "max 20 of each animal per pen". It helps RAM and TPS.
- Lower mob caps. On Paper and Spigot,
spawn-limitsinbukkit.ymlsets the natural mob cap per type (monsters default to 70). Lowering them slightly reduces how many mobs exist at once.
Paper: cap how many entities a chunk can save
Paper has a setting that stops a single chunk from saving thousands of the same entity, which is how lag machines and broken farms bloat a world. In config/paper-world-defaults.yml:
chunks:
entity-per-chunk-save-limit:
experience_orb: 16
arrow: 16
snowball: 8
ender_pearl: 8
The default is -1 (no limit). Only add entity types you're comfortable capping; don't cap mobs players care about, like villagers.
3. Remove heavy and unneeded mods or plugins
On modded servers, the mods themselves are often most of the RAM. Every mod's blocks, items, recipes and worldgen live in memory from startup.
- Remove client-only mods from the server's
modsfolder: minimaps, shaders, sound and HUD mods. They do nothing on a server and some cause crashes. - Question every big content mod. One large tech or worldgen mod can use more memory than dozens of small ones.
- Add memory-saving mods. FerriteCore and ModernFix are popular performance mods that reduce memory use on Fabric, Forge and NeoForge. Check they support your exact Minecraft version and loader before adding them.
- Plugins: most are light, but live web maps and plugins that log every block change can grow large. Remove what you don't use. Run
/spark heapsummaryto see which classes take the most memory; plugin and mod names in that list are a strong hint.
4. Pre-generate the world
Generating new terrain is much more expensive than loading chunks that already exist, and when several players explore in different directions at once, memory and CPU spike together. Pre-generating with a tool like Chunky does that work in advance, at a controlled pace, so exploring later just loads saved chunks.
Run it when the server is quiet, because the pre-gen itself is busy while it works. Full steps: how to pre-generate your world. Adding a world border keeps the world from growing past the area you generated.
5. Set -Xmx correctly (and not too high)
-Xmx is the heap limit, but Java also uses memory outside the heap for threads, loaded classes and native code. If the heap plus that overhead goes past your plan's real limit, the system kills the server with no Java error at all.
- Hosted server: set
-Xmxabout 1 to 1.5 GB below your plan's memory. A 6 GB plan gets about-Xmx5G. - Self-hosted: leave room for your operating system and anything else running.
- Don't add a second
-Xmxif your host already sets one from the plan size. Java uses the last one on the line.
Setting RAM higher than you need doesn't make the server faster. If the heap is huge but mostly empty, you're just making garbage collection deal with a bigger space. Our RAM sizing guide has realistic numbers by server type.
6. Smaller things that help
- Restart regularly. A daily restart clears out anything that's been building up, like a plugin with a slow leak. See automatic restarts.
- Unload unused worlds. Extra worlds from Multiverse or old event maps stay in memory while they're loaded, even with nobody in them.
- Use Paper instead of Vanilla or Spigot if you're not running mods. It has many settings like the one above that Vanilla doesn't.
- Keep everything updated. Memory leaks in mods and plugins get fixed in newer versions.
On FreaksMC you can change these settings from the panel's Files tab and check memory use from the Console.
Quick checklist
- Check real heap use with
/spark health show --memory, not just the panel graph - Lower
view-distanceandsimulation-distance - Cull animals, fix farms, clear item piles
- On Paper, add an
entity-per-chunk-save-limit - Remove client-only and unused mods; consider FerriteCore and ModernFix
- Pre-generate the world and set a world border
- Set
-Xmx1 to 1.5 GB under your plan's limit, and not higher than you need
Want a server that just runs fast?
FreaksMC servers run on AMD Ryzen 9 7950X3D processors with fast NVMe storage. Pick vanilla, Paper or a modpack and your server is ready in minutes.
See plans from $4/mo