public function check()
{
Timings::$memoryManagerTimer->startTiming();
if (($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate) {
$this->checkTicker = 0;
$memory = Utils::getMemoryUsage(true);
$trigger = false;
if ($this->memoryLimit > 0 and $memory[0] > $this->memoryLimit) {
$trigger = 0;
} elseif ($this->globalMemoryLimit > 0 and $memory[1] > $this->globalMemoryLimit) {
$trigger = 1;
}
if ($trigger !== false) {
if ($this->lowMemory and $this->continuousTrigger) {
if (++$this->continuousTriggerTicker >= $this->continuousTriggerRate) {
$this->continuousTriggerTicker = 0;
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0, ++$this->continuousTriggerCount);
}
} else {
$this->lowMemory = true;
$this->continuousTriggerCount = 0;
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0);
}
} else {
$this->lowMemory = false;
}
}
if ($this->garbageCollectionPeriod > 0 and ++$this->garbageCollectionTicker >= $this->garbageCollectionPeriod) {
$this->garbageCollectionTicker = 0;
$this->triggerGarbageCollector();
}
Timings::$memoryManagerTimer->stopTiming();
}