mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Destroy cycles that reference player for faster collection
This commit is contained in:
parent
b166628940
commit
f7e6246dc2
@ -262,8 +262,7 @@ class MemoryManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
|
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
|
||||||
gc_enable();
|
gc_disable();
|
||||||
gc_collect_cycles(); //Cleanup counts
|
|
||||||
|
|
||||||
if(!file_exists($outputFolder)){
|
if(!file_exists($outputFolder)){
|
||||||
mkdir($outputFolder, 0777, true);
|
mkdir($outputFolder, 0777, true);
|
||||||
@ -347,6 +346,8 @@ class MemoryManager{
|
|||||||
|
|
||||||
echo "[Dump] Finished!\n";
|
echo "[Dump] Finished!\n";
|
||||||
|
|
||||||
|
gc_enable();
|
||||||
|
|
||||||
$this->server->forceShutdown();
|
$this->server->forceShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2911,8 +2911,16 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
if($this->perm !== null){
|
if($this->perm !== null){
|
||||||
$this->perm->clearPermissions();
|
$this->perm->clearPermissions();
|
||||||
|
$this->perm = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->inventory !== null){
|
||||||
|
$this->inventory = null;
|
||||||
|
$this->currentTransaction = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->chunk = null;
|
||||||
|
|
||||||
$this->server->removePlayer($this);
|
$this->server->removePlayer($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,11 @@ abstract class BaseInventory implements Inventory{
|
|||||||
$this->setContents($items);
|
$this->setContents($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct(){
|
||||||
|
$this->holder = null;
|
||||||
|
$this->slots = [];
|
||||||
|
}
|
||||||
|
|
||||||
public function getSize(){
|
public function getSize(){
|
||||||
return $this->size;
|
return $this->size;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class PermissibleBase implements Permissible{
|
|||||||
private $opable = null;
|
private $opable = null;
|
||||||
|
|
||||||
/** @var Permissible */
|
/** @var Permissible */
|
||||||
private $parent;
|
private $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PermissionAttachment[]
|
* @var PermissionAttachment[]
|
||||||
@ -50,11 +50,14 @@ class PermissibleBase implements Permissible{
|
|||||||
$this->opable = $opable;
|
$this->opable = $opable;
|
||||||
if($opable instanceof Permissible){
|
if($opable instanceof Permissible){
|
||||||
$this->parent = $opable;
|
$this->parent = $opable;
|
||||||
}else{
|
|
||||||
$this->parent = $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct(){
|
||||||
|
$this->parent = null;
|
||||||
|
$this->opable = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -130,7 +133,7 @@ class PermissibleBase implements Permissible{
|
|||||||
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = new PermissionAttachment($plugin, $this->parent);
|
$result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this);
|
||||||
$this->attachments[spl_object_hash($result)] = $result;
|
$this->attachments[spl_object_hash($result)] = $result;
|
||||||
if($name !== null and $value !== null){
|
if($name !== null and $value !== null){
|
||||||
$result->setPermission($name, $value);
|
$result->setPermission($name, $value);
|
||||||
@ -168,12 +171,12 @@ class PermissibleBase implements Permissible{
|
|||||||
|
|
||||||
$this->clearPermissions();
|
$this->clearPermissions();
|
||||||
$defaults = Server::getInstance()->getPluginManager()->getDefaultPermissions($this->isOp());
|
$defaults = Server::getInstance()->getPluginManager()->getDefaultPermissions($this->isOp());
|
||||||
Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent);
|
Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent !== null ? $this->parent : $this);
|
||||||
|
|
||||||
foreach($defaults as $perm){
|
foreach($defaults as $perm){
|
||||||
$name = $perm->getName();
|
$name = $perm->getName();
|
||||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, null, true);
|
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, null, true);
|
||||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||||
$this->calculateChildPermissions($perm->getChildren(), false, null);
|
$this->calculateChildPermissions($perm->getChildren(), false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +189,11 @@ class PermissibleBase implements Permissible{
|
|||||||
|
|
||||||
public function clearPermissions(){
|
public function clearPermissions(){
|
||||||
foreach(array_keys($this->permissions) as $name){
|
foreach(array_keys($this->permissions) as $name){
|
||||||
Server::getInstance()->getPluginManager()->unsubscribeFromPermission($name, $this->parent);
|
Server::getInstance()->getPluginManager()->unsubscribeFromPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent);
|
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent !== null ? $this->parent : $this);
|
||||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent);
|
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent !== null ? $this->parent : $this);
|
||||||
|
|
||||||
$this->permissions = [];
|
$this->permissions = [];
|
||||||
}
|
}
|
||||||
@ -204,8 +207,8 @@ class PermissibleBase implements Permissible{
|
|||||||
foreach($children as $name => $v){
|
foreach($children as $name => $v){
|
||||||
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
|
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
|
||||||
$value = ($v xor $invert);
|
$value = ($v xor $invert);
|
||||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, $attachment, $value);
|
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, $attachment, $value);
|
||||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||||
|
|
||||||
if($perm instanceof Permission){
|
if($perm instanceof Permission){
|
||||||
$this->calculateChildPermissions($perm->getChildren(), !$value, $attachment);
|
$this->calculateChildPermissions($perm->getChildren(), !$value, $attachment);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user