Memory leak when used with Mythicdungeons

Summary

Our server is a rpg server that uses the mm + md. We found that the server crashes more often when there are more dungeons are opened. We performed a small experiment (on a test server) that shows that mm potentially has some memory leak issue when new worlds are loaded.

Steps to reproduce

We are using paper 1.19.2 build 173 + mm 5.2.3 dev build + md 1.1.1 Our experiment process is as follows:

  1. Open md worlds and leave the md world, repeat the process until the server crashes due to outofmemory
  2. Remove our plugins one by one until finding the plugin that is causing the crash

Using the method above, we find that when mm is installed, we can only open around 5 md dungeons before crash. But when mm is not installed, the server wont crash and the memory is freed when the md worlds are unloaded.

Current behavior

MM seems to hold the memory even after the md world is unloaded.

Intended correct behavior

MM will free the memory when md worlds are closed or unloaded.

Server log file

https://pastebin.com/wVt2fLcJ

Debug log snippet

https://pastebin.com/0rjL5CXV

Proposed fixes

Describe what you think the issue or any potential fixes may be.

Edited by jahua50