henkelmax / easy-villagers

Never get annoyed by villagers again!
59 stars 26 forks source link

Memory Leak of Client Level #240

Closed pietro-lopes closed 3 months ago

pietro-lopes commented 3 months ago

Bug description

This cache is leaking the level https://github.com/henkelmax/easy-villagers/blob/b3d24820ff8bc995f49226ffe6b7c36a118b077a/src/main/java/de/maxhenkel/easyvillagers/datacomponents/VillagerBlockEntityData.java#L33

image

Minecraft version

1.21.1

Mod version

1.21.1-1.1.19

Mod loader and version

NeoForge 21.1.28

Steps to reproduce

With EMI installed

  1. Join world
  2. Do some search on EMI
  3. Leave world to main screen
  4. Join world again
  5. Check memory for some hanging ClientLevel

Expected behavior

Should have a cleanup strategy to clear those cache on LevelEvent.Unload, maybe? Pick what you know it is best.

Log files

screenshot posted

Screenshots

No response

pietro-lopes commented 3 months ago

Also, some renderers are holding entity, you need to find a way to clean up if the level is unloaded.

henkelmax commented 3 months ago

Thank you for bringing this to my attention! I think I've fixed all the leaks by using weak references. Please let me know if you find anything else.