[BUG] Memory leak when unloading worlds
LaserSlime opened this issue · 4 comments
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:
- Start a server with VoxelSniper, Spark profiler and a plugin to load/unload worlds
- Load, join and unload a few worlds
- Run /spark heapdump
- Put the generated heapdump into a tool like eclipse mat and go to "Dominator Tree"
- 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.
Desktop (please complete the following information):
- Minecraft version: 1.19.4
- Voxelsniper version 8.12.2
- Server/client software Paper
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.
Thanks for the report. We do indeed cache worlds in sime way, I'll look into this when I get the change
@LaserSlime Could you elaborate on "a plugin to load/unload worlds"? What plugin could we reproduce the issue with?
It should happen with any plugin that uses Bukkit.unloadWorld. Maybe try Multiverse?
I've addressed this issue. The fix will be in the next release