mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Fixed Player/NetworkSession/SessionHandler cycle memory leak
NetworkSession and some SessionHandlers hold cyclic refs to each other, stopping them getting destroyed. Unfortunately, these also reference the player, stopping that getting destroyed too. The cycle garbage collector will deal with this, but it's best to get rid of the cyclic refs for immediate collection.
This commit is contained in:
parent
fe1df70923
commit
cc84ec8629
@ -228,6 +228,7 @@ class NetworkSession{
|
||||
}
|
||||
|
||||
$this->interface->close($this, $notify ? $reason : "");
|
||||
$this->disconnectCleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,9 +241,16 @@ class NetworkSession{
|
||||
if($this->connected){
|
||||
$this->connected = false;
|
||||
$this->player->close($this->player->getLeaveMessage(), $reason);
|
||||
$this->disconnectCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private function disconnectCleanup() : void{
|
||||
$this->handler = null;
|
||||
$this->interface = null;
|
||||
$this->player = null;
|
||||
}
|
||||
|
||||
//TODO: onEnableEncryption() step
|
||||
|
||||
public function onLoginSuccess() : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user