EngineHub / WorldEdit

🗺️ Minecraft map editor and mod
https://enginehub.org/worldedit/
Other
3.05k stars 826 forks source link

OutOfMemoryError when using WorldEdit #2522

Closed Supermarcel10 closed 2 months ago

Supermarcel10 commented 2 months ago

WorldEdit Version

7.2.12

Platform Version

Forge 1.19.2-43.3.8

Confirmations

Bug Description

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "WorldEdit Session Manager"

No further stack-trace. Crash report

Expected Behavior

No exception should be thrown.

Reproduction Steps (In my case)

  1. Create a container with predefined CPU threads and Memory.
  2. Install FTB Skies Expert modpack with the default configuration.
  3. Install WorldEdit 7.2.12 and add to container/mods/ directory.
  4. Run server and the server thread kills itself during start-up.

Steps to Fix

  1. Edit Java execution to include -XX:MaxRAMPercentage=95.0 or similar.
  2. Rerun the server and no exception occurs.
Supermarcel10 commented 2 months ago

Upon investigating further, it doesn't seem to be an issue with the modpack, but rather entirely WorldEdit. It seems there is a bug with how WorldEdit calculates something based on allocated memory.

When using a container (which was my case), I didn't set a max memory size, since I didn't have the need to - I just allowed it to use as much as the container has assigned for CPU, Mem and Disk.

It seems to be an issue with WorldEdit basing something on the allocated memory size, either using -XX:MaxRAMPercentage=95.0 or -Xmx{MEMORY_SIZE}m. It would probably be a wise idea to get that checked and fixed either way, since it doesn't seem so smart to kill the entire main thread because WorldEdit felt like it.

me4502 commented 2 months ago

You most likely have a very broken mod that's abusing the concept of block states. Mods like WorldEdit inherently need to list all block states that exist in the game, which is a near-instant and fairly light process.

If a mod abuses block states to the point where there are hundreds of millions on the server, then it can take a while and use a lot of resources. This is an issue with whatever mod is abusing block states, as that data should be in BlockEntity data at that point. In newer versions we have detectors that will tell you what mods are causing these issues.