KevinDaGame / VoxelSniper-Reimagined

The premier long-distance brush editor for Minecraft, reimagined!
GNU Lesser General Public License v2.1
62 stars 6 forks source link

[BUG] Memory leak when unloading worlds #212

Closed LaserSlime closed 1 year ago

LaserSlime commented 1 year ago

Describe the bug The plugin somewhere keeps references to chunks or other elements of worlds even after they are unloaded using Bukkit.unloadWorld by other plugins.

To Reproduce Steps to reproduce the behavior:

  1. Start a server with VoxelSniper, Spark profiler and a plugin to load/unload worlds
  2. Load, join and unload a few worlds
  3. Run /spark heapdump
  4. Put the generated heapdump into a tool like eclipse mat and go to "Dominator Tree"
  5. You should see lots of instances of ChunkTaskScheduler as well as WorldServer and other world related classes that take up memory (see screenshot)

Expected behavior If you repeat the same steps without VoxelSniper, this should not happen.

Screenshots i love it when ChunkTaskScheduler

Desktop (please complete the following information):

Additional context I was told by the paper devs that unloadWorld memory leaks really only happen due to other plugins keeping references to chunks. When I removed all plugins except for one that unloads worlds and spark, it did indeed stop. So I added every single plugin back 1 by 1 and tested and as soon as I added VoxelSniper, I could see lots of ChunkTaskScheduler instances in the heap dump.

KevinDaGame commented 1 year ago

Thanks for the report. We do indeed cache worlds in sime way, I'll look into this when I get the change

KevinDaGame commented 1 year ago

@LaserSlime Could you elaborate on "a plugin to load/unload worlds"? What plugin could we reproduce the issue with?

LaserSlime commented 1 year ago

It should happen with any plugin that uses Bukkit.unloadWorld. Maybe try Multiverse?

KevinDaGame commented 1 year ago

I've addressed this issue. The fix will be in the next release