[Bug] Memory Leak of Client Player
pietro-lopes opened this issue ยท 8 comments
Observed behaviour
Continuation of #549
Now it is holding on ClientMagicData on 3.4.5
Expected behaviour
No leak
Steps to reproduce
Same as old issue.
Server Type
Single Player
Crashlog
No response
Iron's Spells N Spellbooks version
3.4.5
Forge version
1.21.1 - 21.1.22
Other mods
No response
The SpellSelectionManager and the SpellBarOverlay do not store a reference to ClientMagicData, nor does any class
That SpellSelectionManager is thrown away when the player exits the world
https://github.com/iron431/irons-spells-n-spellbooks/blob/1.21/src/main/java/io/redspace/ironsspellbooks/player/ClientPlayerEvents.java#L70C15-L70C16
I see, but that does not include dimension change or death. Both triggers player creation again.
We don't have something similar to PlayerEvent.StopTracking on client side, so I don't know which event should be used for both cases (player dim change and death)
I would just not store player and replace player with Minecraft.getInstance().player
, this is not an expensive call, unless there is something I'm missing that you shouldn't use.
OH, I forgot about ClientPlayerNetworkEvent.Clone
, you can listen to that to replace/clear player.
Not 100% but Issue still seems to exist. I've been messing around exculsivley with Iron's Spells and Spellbooks and the symptoms started up. I know it's not very helpful, but figured you'd want to know. If it helps, I notice it most often when swapping spellbooks or washing scrolls for ink. Will test a bit more tomorrow. Seems likely related to either the Cauldron or the Spell UI (Only 2 consistent things present that I can see so far). Yeah, about 75% sure it's related to the cauldron. Rapidly increases memory allocation to 100% even when no armor or spellbooks equipped. Even at 100% (before final stage of lag spikes) I was able to equip and run around casting for quite a while without locking up.
it is not possible for the spell selection manager to affect the memory usage of the cauldron
I'll admit I know nothing about how the mod is coded. Just reporting what I saw. Basically if I'm doing either the scroll to ink or ink upgrade process, the memory leak happens rather quickly (admittedly working in batches of a few hundred scrolls/inks). That was the repeatable result of my testing. If I'm wrong, fair enough. I just am enjoying the mod other than the leak, so I wanted to help you narrow down possibilities.