Anvil fixes, improved memory settings

This commit is contained in:
Shoghi Cervantes
2015-04-19 11:45:43 +02:00
parent 5860bdcc4d
commit e3c48b22cb
16 changed files with 61 additions and 46 deletions

View File

@ -33,10 +33,12 @@ class LowMemoryEvent extends ServerEvent{
private $memory;
private $memoryLimit;
private $triggerCount;
private $global;
public function __construct($memory, $memoryLimit, $triggerCount = 0){
public function __construct($memory, $memoryLimit, $isGlobal = false, $triggerCount = 0){
$this->memory = $memory;
$this->memoryLimit = $memoryLimit;
$this->global = (bool) $isGlobal;
$this->triggerCount = (int) $triggerCount;
}
@ -67,13 +69,20 @@ class LowMemoryEvent extends ServerEvent{
return $this->triggerCount;
}
/**
* @return bool
*/
public function isGlobal(){
return $this->global;
}
/**
* Amount of memory already freed
*
* @return int
*/
public function getMemoryFreed(){
return $this->getMemory() - Utils::getMemoryUsage();
return $this->getMemory() - ($this->isGlobal() ? Utils::getMemoryUsage(true)[1] : Utils::getMemoryUsage(true)[0]);
}
}