Skip to main content
criticalJava ErrorsAffects: 1.17+

How to Fix OutOfMemoryError: Metaspace

Fix OutOfMemoryError Metaspace in Minecraft by increasing the MaxMetaspaceSize JVM flag and reducing loaded mods.

Quick Fix

Add -XX:MaxMetaspaceSize=512m to your JVM arguments.

Error Message

java.lang.OutOfMemoryError: Metaspace

How to Fix

1

Add -XX:MaxMetaspaceSize=512m to JVM arguments

2

Reduce the number of installed mods

3

Update all mods to their latest compatible versions

4

Restart the game or server periodically to free metaspace

Common Causes

  • Too many mods loading classes into memory
  • Class loader leak from hot-reloading plugins
  • Default metaspace limit too low for modded Minecraft

Diagnostic Steps

  1. Check how many mods are loaded in the mod menu
  2. Add the MaxMetaspaceSize flag and restart
  3. Monitor if the error reoccurs after increasing metaspace

FAQ

What is Metaspace in Java?

Metaspace is where Java stores class metadata. Mods load many classes, which can exhaust this space if the limit is too low.

Related Errors

Need More Help?