EngineHub / WorldEdit

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

World Edit causes MASSIVE memory leak in server. #2488

Closed dooblykid closed 3 months ago

dooblykid commented 6 months ago

WorldEdit Version

7.2.15

Platform Version

Forge 47.2.20

Confirmations

Bug Description

World edit seems to inflate the heap for servers to sizes that pretty much cause the server to lag out. It took me forever to find out what mod was causing the tps to drop because I thought it was a mod that adds content and features. But somehow it's being caused by world edit. I extracted the Heap using spark and was able to get this information. World edit is currently causing a memory leak that occupies 1.1 GB worth of Memory. Which makes my server unplayable when world edit is installed.

I have provided the full heap file so someone with more knowledge can get to the bottom of this.

heap-2024-03-15_05.04.56_Leak_Suspects.zip

`469,374 instances of “com.sk89q.worldedit.world.block.BlockState”, loaded by “cpw.mods.modlauncher.TransformingClassLoader @ 0x686293dc8” occupy 1,204,680,040 (40.96%) bytes.

Most of these instances are referenced from one instance of “java.lang.Object[]”, loaded by “”, which occupies 4,194,328 (0.14%) bytes. The instance is referenced by “it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap @ 0x6d100fa38”, loaded by “cpw.mods.cl.ModuleClassLoader @ 0x68319eaa8”.

Thread “java.lang.Thread @ 0x6c7664080 FileSystemWatchService” has a local variable or reference to “cpw.mods.modlauncher.TransformingClassLoader @ 0x686293dc8” which is on the shortest path to “java.lang.Object[1048577] @ 0x713000000”. The thread java.lang.Thread @ 0x6c7664080 FileSystemWatchService keeps local variables with total size 528 (0.00%) bytes.

The stacktrace of this Thread is available. See stacktrace. See stacktrace with involved local variables.

Keywords com.sk89q.worldedit.world.block.BlockState cpw.mods.modlauncher.TransformingClassLoader java.lang.Object[] it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap cpw.mods.cl.ModuleClassLoader`

Expected Behavior

I expect it not to do this?

Reproduction Steps

  1. Host a server with World Edit
  2. ...Thats it

Anything Else?

No response

me4502 commented 6 months ago

WorldEdit needs to inherently store a list of all blocks that exist, which is what your memory dump indicates is taking 1.2GB of space. This isn't a memory leak, this is another mod on your server massively abusing the concept of block states, leading to massive pollution of the block state list.

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not been fully confirmed. It will be closed if no further activity occurs. Thank you for your contributions.