What the error means
Java gives Minecraft a fixed pool of memory, the heap, and when the game asks for more than the pool holds it stops with this:
java.lang.OutOfMemoryError: Java heap spaceThe pool is smaller than your computer's RAM on purpose. The Minecraft Launcher starts the game with -Xmx2G, so 2 GB, which is plenty for vanilla and not enough for a big modpack or a busy server.
Two cousins. GC overhead limit exceeded is the same problem: Java spent nearly all its time cleaning up and got almost nothing back. unable to create native thread is different. It's a system limit, not the heap, and more memory usually makes it worse.
Give the game more memory
Most launchers have a memory setting per instance:
- Minecraft Launcher: Installations, the three dots on your version, Edit, More options. In JVM arguments, change
-Xmx2Gto something bigger, like-Xmx4G. - Prism Launcher: instance settings, Java, then raise Maximum memory allocation.
- Anything else: look for Memory, RAM or Java in the instance or launcher settings.
G is gigabytes, so -Xmx4G caps the game at 4 GB. Pick a number the machine can spare. On a 16 GB computer, 6 to 8 GB for the game is a sensible ceiling; leave the rest for the system, or everything slows down.
Give a server more memory
On a server it's the start command. Change the -Xmx number, and set -Xms to match:
java -Xms4G -Xmx4G -jar server.jar noguiOn a hosting panel there's usually a RAM slider instead, and your plan sets how far it goes.
When more memory doesn't help
Bigger isn't automatically better. Java has to sweep the heap now and then, and a very large one makes those pauses longer, which shows up as lag. If you raised the number and the error came back, it's probably something else:
- A mod or plugin that eats more memory the longer the game runs, a leak. A crash that always arrives after an hour or two is the tell.
- A high render distance, heavy shaders or a 512x resource pack on the client.
- Too many loaded chunks or entities on a server.
The crash report and latest.log show what was running when memory ran out. How to read a Minecraft crash report shows where to look.
If Java says there isn't enough memory to start
There is insufficient memory for the Java Runtime Environment to continue, usually inside a file named hs_err_pid plus a number, means the computer itself is out of memory. It's the opposite problem: you asked Java for more than the machine has free. Lower the number or close other programs.
Questions
How much RAM does Minecraft need?
Vanilla is fine on a few gigabytes. Modpacks and busy servers want more, often 4 to 8 GB, and the modpack's page usually says how much. Never hand Java more than the computer can spare.
What does -Xmx mean?
The largest amount of memory Java may use: -Xmx4G is 4 gigabytes at most. -Xms is how much it grabs at startup.
Why does Minecraft still run out of memory after I gave it more?
Probably something is holding on to memory, like a mod or plugin with a leak. If it always dies after about the same playing time, that's your answer.
Keep reading
- How to read a Minecraft crash reportA crash report looks like a wall of text, but the answer is usually in three places. Learn what Description, the stack trace and Caused by lines mean.
- How to fix "Could not reserve enough space for object heap"Java refused to start because the memory it was asked for wasn't available. The usual causes are too much RAM, a 32-bit Java and an -Xms bigger than -Xmx.
- How to find your Minecraft logsFind latest.log and crash reports for the Minecraft client, servers and launchers like Prism and Modrinth App. Paths for Windows, macOS and Linux.