Skip to main content
criticalJava ErrorsAffects: All versions

How to Fix java.lang.OutOfMemoryError

Fix the java.lang.OutOfMemoryError in Minecraft by increasing RAM allocation, optimizing settings, and removing memory-heavy mods.

Quick Fix

Increase allocated RAM to at least 4GB in your launcher JVM arguments: -Xmx4G -Xms2G

Error Message

java.lang.OutOfMemoryError: Java heap space

How to Fix

1

Open your launcher, go to Installations, edit your profile, and set JVM arguments to -Xmx4G -Xms2G

2

Lower your render distance to 8-12 chunks

3

Remove unused mods and resource packs

4

Update Java to the latest version (Java 21 for 1.21+)

5

Close other memory-heavy programs while playing

6

If using a server, increase the -Xmx value in start.sh or start.bat

Common Causes

  • Not enough RAM allocated to Minecraft
  • Too many mods or resource packs loaded
  • Memory leak from a mod or plugin
  • Large render distance with limited RAM

Diagnostic Steps

  1. Check current RAM allocation in launcher settings
  2. Verify Java version with java -version in terminal
  3. Monitor memory usage with F3 debug screen in-game
  4. Remove mods one by one if the issue persists after increasing RAM

FAQ

How much RAM should I allocate to Minecraft?

4-6GB for modded, 2-4GB for vanilla. Never allocate more than 75% of your total system RAM.

Why does Minecraft keep running out of memory?

Usually caused by too many mods, high render distance, or a memory leak. Try reducing mods and render distance first.

Related Errors

Need More Help?