mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Bumped to API 2.0.0
This commit is contained in:
parent
fabb632286
commit
d7d05c20a9
@ -214,87 +214,6 @@ class MemoryManager{
|
|||||||
return $cycles;
|
return $cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $object
|
|
||||||
*
|
|
||||||
* @return string Object identifier for future checks
|
|
||||||
*/
|
|
||||||
public function addObjectWatcher($object){
|
|
||||||
if(!is_object($object)){
|
|
||||||
throw new \InvalidArgumentException("Not an object!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$identifier = spl_object_hash($object) . ":" . get_class($object);
|
|
||||||
|
|
||||||
if(isset($this->leakInfo[$identifier])){
|
|
||||||
return $this->leakInfo["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->leakInfo[$identifier] = [
|
|
||||||
"id" => $id = md5($identifier . ":" . $this->leakSeed++),
|
|
||||||
"class" => get_class($object),
|
|
||||||
"hash" => $identifier
|
|
||||||
];
|
|
||||||
$this->leakInfo[$id] = $this->leakInfo[$identifier];
|
|
||||||
|
|
||||||
$this->leakWatch[$id] = new \WeakRef($object);
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isObjectAlive($id){
|
|
||||||
if(isset($this->leakWatch[$id])){
|
|
||||||
return $this->leakWatch[$id]->valid();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeObjectWatch($id){
|
|
||||||
if(!isset($this->leakWatch[$id])){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
unset($this->leakInfo[$this->leakInfo[$id]["hash"]]);
|
|
||||||
unset($this->leakInfo[$id]);
|
|
||||||
unset($this->leakWatch[$id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doObjectCleanup(){
|
|
||||||
foreach($this->leakWatch as $id => $w){
|
|
||||||
if(!$w->valid()){
|
|
||||||
$this->removeObjectWatch($id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getObjectInformation($id, $includeObject = false){
|
|
||||||
if(!isset($this->leakWatch[$id])){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$valid = false;
|
|
||||||
$references = 0;
|
|
||||||
$object = null;
|
|
||||||
|
|
||||||
if($this->leakWatch[$id]->acquire()){
|
|
||||||
$object = $this->leakWatch[$id]->get();
|
|
||||||
$this->leakWatch[$id]->release();
|
|
||||||
|
|
||||||
$valid = true;
|
|
||||||
$references = getReferenceCount($object, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
"id" => $id,
|
|
||||||
"class" => $this->leakInfo[$id]["class"],
|
|
||||||
"hash" => $this->leakInfo[$id]["hash"],
|
|
||||||
"valid" => $valid,
|
|
||||||
"references" => $references,
|
|
||||||
"object" => $includeObject ? $object : null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
|
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
|
||||||
gc_disable();
|
gc_disable();
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace pocketmine {
|
|||||||
use pocketmine\wizard\Installer;
|
use pocketmine\wizard\Installer;
|
||||||
|
|
||||||
const VERSION = "1.6dev";
|
const VERSION = "1.6dev";
|
||||||
const API_VERSION = "1.13.0";
|
const API_VERSION = "2.0.0";
|
||||||
const CODENAME = "[REDACTED]";
|
const CODENAME = "[REDACTED]";
|
||||||
const MINECRAFT_VERSION = "v0.12.1 alpha";
|
const MINECRAFT_VERSION = "v0.12.1 alpha";
|
||||||
const MINECRAFT_VERSION_NETWORK = "0.12.1";
|
const MINECRAFT_VERSION_NETWORK = "0.12.1";
|
||||||
|
@ -24,8 +24,8 @@ namespace pocketmine\metadata;
|
|||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
|
|
||||||
abstract class MetadataValue{
|
abstract class MetadataValue{
|
||||||
/** @var \WeakRef<Plugin> */
|
/** @var Plugin */
|
||||||
protected $owningPlugin;
|
private $owningPlugin;
|
||||||
|
|
||||||
protected function __construct(Plugin $owningPlugin){
|
protected function __construct(Plugin $owningPlugin){
|
||||||
$this->owningPlugin = new \WeakRef($owningPlugin);
|
$this->owningPlugin = new \WeakRef($owningPlugin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user