Mo' Bends

Mo' Bends

29M Downloads

(1.12) Memory Leak: ModConfig#keepEntityAsVanillaCache

Meldexun opened this issue ยท 1 comments

commented

Describe the bug
Entries of the map ModConfig#keepEntityAsVanillaCache use entity instances as their keys. This means for every sheep entity for example there will be an entry in the map. Because the map is never cleared this means in theory the map will fill up more and more and require more and more memory.
The other problem with using entities as keys is that the entity object has a world field and thus a lot of other objects will also remain in memory despite not being used anymore.

Changing the map to Map<Class<? extends Entity>, Boolean> should fix these issues while still working the same as before.

private static Map<Entity, Boolean> keepEntityAsVanillaCache;

To Reproduce
Steps to reproduce the behavior:

  1. Join a world
  2. Leave the world
  3. See WorldClient instance not being garbage collected

Context (please complete the following information):

  • Minecraft version: 1.12.2
  • Forge version: 14.23.5.2855
  • Mo' Bends version: 1.1.0
commented

Good point! An overlook on my part, I'll tend to all the issues you've posted soon. Thanks for reporting them!