static::$memoryConsumption + static::$memoryDiffMb) { \gc_collect_cycles(); static::$memoryConsumption = static::getMemoryConsumption(); $cleanedMemory = $currentMemory - static::$memoryConsumption; if (static::$log) { Logger::log("gc_collect_cycles done. Cleaned memory: $cleanedMemory Mb", Logger::VERBOSE); } } }); } private static function getMemoryConsumption(): int { $memory = \round(\memory_get_usage()/1024/1024, 1); if (static::$log) { Logger::log("Memory consumption: $memory Mb", Logger::ULTRA_VERBOSE); } return (int) $memory; } }