Memory Leak when using MythicMobs and ModelEngine with multiple worlds
Summary
I am creating multiple worlds, spawning mythic mobs there and unloading the world there. After around 2h, my 8gb server is running out of memory. I am creating around 1 map every 5-10 seconds.
Steps to reproduce
Create new empty world, paste schematic there, spawn mobs (around 100-200), delete all entities there with entity.remove() and then unload the world. Some mobs keep getting in the memory as in the screenshot and keep the world in the memory causing the memory leak
Current behavior
thats what i wrote in reproduce steps
Intended correct behavior
mobs should be removed from the list when the world is unloaded or perform a check every minute or so to remove them if the world was deleted
Server log file
nothing interesting there, just a normal out of memory exception but I appended heap dump screenshots here
Debug log snippet
same as server log file
Proposed fixes
either they are sometimes not removed when the world is unloaded/deleted -> fix there or perform a check every 10-20 seconds to remove activemobs that are in a deleted or unloaded world. the entity of the activemob is probably already removed so that might also work to check