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:
Dylan K. Taylor 2018-07-22 13:41:06 +01:00
parent fe1df70923
commit cc84ec8629

View File

@ -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{