protected function useThread() { if ('auto' == $this->getOption('use_thread')) { $useThread = false; if (dmConfig::canSystemCall()) { $apacheMemoryLimit = dmString::convertBytes(ini_get('memory_limit')); if ($apacheMemoryLimit < 64 * 1024 * 1024) { $filesystem = $this->serviceContainer->getService('filesystem'); if ($filesystem->exec('php -r "die(ini_get(\'memory_limit\'));"')) { $cliMemoryLimit = dmString::convertBytes($filesystem->getLastExec('output')); $useThread = $cliMemoryLimit >= $apacheMemoryLimit; } } } $this->setOption('use_thread', $useThread); } return $this->getOption('use_thread'); }
protected function willRunOutOfMemory() { return ini_get('memory_limit') > -1 && dmString::convertBytes(ini_get('memory_limit')) - memory_get_usage() < 5 * 1024 * 1024; }