Genetics: Resequenced

Genetics: Resequenced

202k Downloads

[Memory Leak] ServerPlayer is leaked when a player dies

pietro-lopes opened this issue ยท 1 comments

commented

Describe the bug
When a player dies, InventoryListener.allListeners holds an instance of dead player
To Reproduce
Steps to reproduce the behavior:

  1. Login
  2. /kill @s
  3. 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.

commented

Bit the bullet and figured out how ItemSubPredicates worked, and moved to those instead of having an InventoryListener