How to Fix java.lang.OutOfMemoryError in Minecraft

When you’re joining a Minecraft server or your singleplayer world, you might encounter a set of errors. Let’s find out how to fix java.lang.OutOfMemoryError in Minecraft, which is pretty common with low-end computers.

What Kind of Error Is java.lang.OutOfMemoryError?

Encountering java.lang.OutOfMemoryError in Minecraft

As the name of the error suggests, it’s a memory-related issue. This means that you either don’t have enough space in your computer, or Minecraft can’t use enough RAM. It gets way more complicated than this, though, so let’s check out some solutions.

How to Fix the Minecraft java.lang.OutOfMemoryError Error?

Many Minecraft errors can simply be fixed if you do the following:

  • Restart the Minecraft Launcher.
  • Reboot your computer.

This will usually be enough to fix java.lang.OutOfMemoryError or any other error. But if the issue persists, you’ll have to try more advanced solutions. Thankfully, there are a few ways to fix this error.

Change Your Profile’s JVM Arguments 

Changing the JVM Arguments

Changing your profile’s JVM arguments will allow you to allocate more RAM to Minecraft. The process is pretty simple, and it can be done straight from the Minecraft Launcher:

  1. Open the Minecraft Launcher.
  2. Click on Installations.
  3. Select your Minecraft version, click on the 3 dots, and select “Edit”.
  4. At the bottom of the page, select “More Options”.

At this point, you should see a “Java Executable” and a “JVM Arguments” line. The first argument on the latter should be the following: “-Xmx#G”, or “-Xmx#M”. 

This is the amount of RAM you want to allocate to Minecraft (with M symbolizing megabytes and G symbolizing gigabytes). So, simply input a larger number according to how much RAM you have (i.e. If you have 8GBs of RAM, allocating 2-3 for Minecraft should be enough).

Delete _JAVA_OPTIONS in Environmental Variables

Finding the JAVA_OPTIONS in Environmental Variables

Oftentimes, other software might create a variable to restrict the RAM allocation for Java programs. Deleting this is similar to fixing the JNI Error in Minecraft:

  1. Press the Windows+R key, type “sysdm.cpl”, and press Enter.
  2. Select “Advanced” at the top, and click on “Environment Variables”.

You should locate a _JAVA_OPTIONS variable under “System Variables”, which you’ll need to delete. To do this, click on it and select “Delete”. Once that’s done, restart your computer to see if the java.lang.OutOfMemoryError persists.

Reinstall Java 

If all else fails to fix the error, reinstalling Java should help you out. You can get this done quickly by downloading the Java uninstall tool and installing the latest Java version.

Upgrade Your Device’s RAM

Since the error is memory-related, you might need to upgrade your hardware. If none of the software fixes I mentioned above worked for you, you’ll need additional RAM sticks to run your server or world.

Conclusion

These solutions have hopefully helped you fix java.lang.OutOfMemoryError in Minecraft. You could try reinstalling the game if the error still troubles you. Or, you can check out one of the numerous threads on this issue on the Minecraft Forum for additional help.