[Memory Leak] ServerPlayer is leaked when a player dies
pietro-lopes opened this issue ยท 1 comments
Describe the bug
When a player dies, InventoryListener.allListeners holds an instance of dead player
To Reproduce
Steps to reproduce the behavior:
- Login
/kill @s- Use IDE or do memory dump to check alive objects and you will see at least 2
ServerPlayers
Expected behavior
Maybe use stopListening for dead player instance (grab from Clone event) and startListening for new player instance (BE CAREFUL WITH CLONE EVENT, THE NEW PLAYER INSTANCE WILL CHANGE THE ID AFTER THE EVENT, SO IF YOU STORE IN A HASHSET BEFORE THIS CHANGE IT WILL NEVER HAVE A HASHCODE AS SAME AS IN A LATER MOMENT, USE PlayerEvent.PlayerRespawnEvent TO GRAB THE NEW PLAYER INSTANCE WITH THE FINAL ID/HASH)
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.