mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
Future all-memory impossible cleanup
This commit is contained in:
parent
ed42ba5176
commit
46ded9e675
@ -26,6 +26,29 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function hard_unset(&$var){
|
||||||
|
if(is_object($var)){
|
||||||
|
$unset = new ReflectionClass($var);
|
||||||
|
foreach($unset->getProperties() as $prop){
|
||||||
|
$prop->setAccessible(true);
|
||||||
|
@hard_unset($prop->getValue($var));
|
||||||
|
$prop->setValue($var, null);
|
||||||
|
}
|
||||||
|
$var = null;
|
||||||
|
unset($var);
|
||||||
|
}elseif(is_array($var)){
|
||||||
|
foreach($var as $i => $v){
|
||||||
|
hard_unset($var[$i]);
|
||||||
|
}
|
||||||
|
$var = null;
|
||||||
|
unset($var);
|
||||||
|
}else{
|
||||||
|
$var = null;
|
||||||
|
unset($var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function parseNBTData($data){
|
function parseNBTData($data){
|
||||||
$x = array();
|
$x = array();
|
||||||
if(isset($data["value"])){
|
if(isset($data["value"])){
|
||||||
|
10
server.php
10
server.php
@ -23,7 +23,17 @@ while(true){
|
|||||||
if($server->start() !== true){
|
if($server->start() !== true){
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
|
console("[INFO] Cleaning up...");
|
||||||
|
hard_unset($server);
|
||||||
|
$excludeList = array("GLOBALS", "_FILES", "_COOKIE", "_POST", "_GET", "excludeList");
|
||||||
|
foreach(get_defined_vars() as $key => $value){
|
||||||
|
if(!in_array($key, $excludeList)){
|
||||||
|
$$key = null;
|
||||||
|
unset($$key);
|
||||||
|
}
|
||||||
|
}
|
||||||
$server = null;
|
$server = null;
|
||||||
|
unset($server);
|
||||||
console("[NOTICE] The server is restarting... (".gc_collect_cycles()." cycles collected)", true, true, 0);
|
console("[NOTICE] The server is restarting... (".gc_collect_cycles()." cycles collected)", true, true, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user