Whether you are fixing crashes or just adding a big modpack, your Minecraft server needs the right amount of RAM allocated. Here is how to do it — in a start script and in a control panel — and how much to give.
Quick answer
Change the -Xmx value in the start command: java -Xms6G -Xmx6G -jar server.jar nogui gives the server 6 GB. On a control panel, change the server's memory setting instead. Always leave 1–2 GB for the operating system. As a guide: 2–4 GB for vanilla, 6–8 GB for medium modpacks and 8–10 GB or more for heavy ones.
-Xmx sets the MAXIMUM RAM the server can use; -Xms sets the starting amount. For a dedicated game server, setting both the same (e.g. -Xmx6G -Xms6G) is common and avoids resizing pauses.
Method 1: in your start command / script
If you run the server yourself, the RAM is set by the -Xmx and -Xms flags in your launch command:
java -Xms6G -Xmx6G -jar server.jar noguiThat gives the server 6 GB. Change the number (e.g. 4G, 8G) to suit. Always leave 1–2 GB free for the operating system — never allocate all of the machine's RAM.
Method 2: in a control panel
Most hosts use a panel, so you never touch the command line:
- Pterodactyl — set the memory limit on the server; it applies the
-Xmxautomatically. - Multicraft — set the maximum memory in the server settings.
- Other panels — look for a "Memory" or "RAM" field, then restart.
On shared hosting your plan's RAM is the ceiling — to go higher you upgrade the plan.
How much RAM should you allocate?
- Vanilla / Paper, a few players — 2–4 GB.
- Plugins + 10–30 players — 4–6 GB.
- Medium modpacks — 6–8 GB.
- Large modpacks (All the Mods, RLCraft, Create) — 8–10 GB or more.
More is not always better — beyond what the server needs, extra RAM just sits unused, and very large heaps can even cause longer pauses. Match the RAM to the workload.
After changing RAM
Restart the server for the new value to take effect, then watch for the OutOfMemoryError crash. If it still runs out, you may have a leaking mod or simply need a bigger plan. Pair the right RAM with good settings for smooth TPS.
Give the server what its workload needs plus a little headroom — and always leave RAM for the OS. Bigger is not automatically better.
Use 64-bit Java and tuned flags
Allocating RAM only helps if Java can actually use it — a 32-bit Java install caps out around 4 GB no matter what you set. Run 64-bit Java, and pair a generous heap with a tuned garbage-collection flag set (Aikar's flags) so the extra memory is used smoothly instead of causing long GC pauses.
RAM alone won't fix CPU-bound lag
If your server lags with plenty of free RAM, the bottleneck is usually the CPU or the tick load, not memory — adding RAM won't help. That's the "Can't keep up" / low TPS situation, which is fixed by reducing entity counts, view distance and heavy plugins rather than by allocating more memory.
How to avoid RAM problems later
- Re-check your allocation whenever you add a big modpack or more players.
- Leave OS headroom and never allocate 100% of the machine.
- Pre-generate the world so chunk loading doesn't spike memory during play.
- Watch memory over a few hours after adding mods, to catch a leak early.
Related guides
If you're allocating RAM because of a crash, see OutOfMemoryError: Java heap space. Building the server from scratch? See how to make a Minecraft server. Then lock in smooth performance with the best lag-reducing settings.
Minecraft is a trademark of Mojang Synergies AB / Microsoft. ESAGAMES is an independent hosting provider, not affiliated with or endorsed by Mojang or Microsoft.