Determine if the memory limit has been exceeded.

@return bool
10396
protected function memoryExceeded()
    {
        static $warning_percent = 0.5;

        $percent = (memory_get_usage() / 1024 / 1024) / $this->memoryLimit;

        if ($percent >= $warning_percent) {
            $this->log(sprintf('Memory usage at %d%% (Max %s MB)', round($percent * 100, 1), $this->memoryLimit), Logger::DEBUG);
            $warning_percent = ceil(($percent * 100) / 10) * 10 / 100;
        }

        return $percent > 0.999;
    }
632362
public function maxExecutionTimeExceeded()
    {
        // client went away while waiting for worker
        if (!$this->connectionOpen) {
            return false;
        }

        $this->incoming->write($this->createErrorResponse('504 Gateway Timeout', 'Maximum execution time exceeded'));
        $this->lastOutgoingData = 'not empty'; // Avoid triggering 502

        // mark slave as closed
        $this->slave->close();
        $this->output->writeln(sprintf('Maximum execution time of %d seconds exceeded. Closing worker.', $this->maxExecutionTime));
        $this->slave->getConnection()->close();
    }
647109
private function do_raise_php_limits()
    {
        $php_limits = array(
            'memory_limit' => $this->memory_limit,
            'max_execution_time' => $this->max_execution_time,
            'pcre.backtrack_limit' => $this->pcre_backtrack_limit,
            'pcre.recursion_limit' =>  $this->pcre_recursion_limit
        );

        // If current settings are higher respect them.
        foreach ($php_limits as $name => $suggested) {
            $current = $this->normalize_int(ini_get($name));
            // memory_limit exception: allow -1 for "no memory limit".
            if ($current > -1 && ($suggested == -1 || $current < $suggested)) {
                ini_set($name, $suggested);
            }
        }
    }
421801
private function hasToBeReloaded()
    {
        if (!$this->getWurflConfig()->allowReload) {
            return false;
        }

        $state = $this->getPersistenceStorage()->load(self::WURFL_API_STATE);

        return !$this->isStateCurrent($state);
    }
680391
public function hasRange()
    {
        return ($this->getOffset() !== false && $this->getOffset() >= 0 && $this->getNumberOfEntries() !== false && $this->getNumberOfEntries() > 0);
    }
545054
public static function getFileUploadLimit()
    {

        $max_upload = self::toBytes(ini_get('upload_max_filesize'));
        $max_post = self::toBytes(ini_get('post_max_size'));
        $memory_limit = self::toBytes(ini_get('memory_limit'));

        $returnValue = min($max_upload, $max_post, $memory_limit);

        return (int)$returnValue;
    }
302103
public function isTimeLimitUp(float $limit = self::TIME_LIMIT): bool
    {
        $now = microtime(true);

        return $now > $this->start_time + $limit;
    }
1333120
def is_rate_limit_exceeded(self):
        """"""
        history = self.get_history()
        if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT:
            return True
        return False
201577
protected function impactLimitReached()
    {
        if ($this->impactLimit < 1) {
            return false;
        }

        $reached = $this->impact >= $this->impactLimit;
        if ($reached) {
            $this->getLogger()->info(
                'Reached Impact limit'
            );
        }
        return $reached;
    }
45461
public function isValid() {
		
		$file = $this -> getFile();

		$messages = [

			UPLOAD_ERR_FORM_SIZE 	=> 'File exceeds the maximum file size that was specified in the HTML form',
			UPLOAD_ERR_PARTIAL 		=> 'File was only partially uploaded',
			UPLOAD_ERR_NO_FILE		=> 'No file was uploaded',
			UPLOAD_ERR_NO_TMP_DIR	=> 'Missing a temporary folder',
			UPLOAD_ERR_CANT_WRITE	=> 'Failed to write file to disk',
			UPLOAD_ERR_EXTENSION	=> 'An extension stopped the file upload'
		];

		if(false === isset($messages[$file['error']])) {
			return true;
		}

		$this -> setMessage($messages[$file['error']]);

		return false;
	}
857699
private function memoryLimit(): int
    {
        $memory_limit = ini_get('memory_limit');

        switch (substr($memory_limit, -1)) {
            case 'k':
            case 'K':
                $memory_limit = substr($memory_limit, 0, -1) / 1024;
                break;
            case 'm':
            case 'M':
                $memory_limit = substr($memory_limit, 0, -1);
                break;
            case 'g':
            case 'G':
                $memory_limit = substr($memory_limit, 0, -1) * 1024;
                break;
            case 't':
            case 'T':
                $memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024;
                break;
            default:
                $memory_limit = $memory_limit / 1024 / 1024;
        }

        return (int) $memory_limit;
    }
456453
public function isExpanded() {
        $baseClass=ClassInfo::baseDataClass($this->owner->class);
        $id=$this->owner->ID;
        return isset(self::$expanded[$baseClass][$id]) ? self::$expanded[$baseClass][$id] : false;
    }
1120751
protected function validateFileSize()
    {
        if (!is_numeric($this->max_file_size) && !is_int($this->max_file_size)) {
            // it is not set max file size limitation.
            return true;
        }

        if (is_array($this->files[$this->input_file_name]) && array_key_exists('size', $this->files[$this->input_file_name]) && $this->files[$this->input_file_name]['size'] > $this->max_file_size) {
            $this->setErrorMessage(
                sprintf(static::__('The uploaded file exceeds the max file size directive. (%s &gt; %s).'), $this->files[$this->input_file_name]['size'], $this->max_file_size),
                'RDU_1',
                $this->files[$this->input_file_name]['size'] . ' &gt; ' . $this->max_file_size,
                $this->files[$this->input_file_name]['name'],
                $this->files[$this->input_file_name]['size'],
                $this->files[$this->input_file_name]['type']
            );
            return false;
        } else {
            if (is_array($this->files[$this->input_file_name]) && array_key_exists('tmp_name', $this->files[$this->input_file_name]) && function_exists('filesize')) {
                if (filesize($this->files[$this->input_file_name]['tmp_name']) > $this->max_file_size) {
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded file exceeds the max file size directive. (%s &gt; %s).'), $this->files[$this->input_file_name]['size'], $this->max_file_size),
                        'RDU_1',
                        $this->files[$this->input_file_name]['size'] . ' &gt; ' . $this->max_file_size,
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                }
            }
        }

        return true;
    }
1149866
public function valid()
    {
        if ($this->timedOut() || $this->limitExceeded()) {
            return false;
        }
        $this->_currentMessage = $this->_agent->getQueue()->consume();
        return $this->_currentMessage !== false;
    }
1303776
public function hasReachedChildrenLimit()
    {
        if ($this->childrenLimit === false) {
            return false;
        }
        if (!is_numeric($this->childrenLimit) || $this->childrenLimit < 0) {
            $this->childrenLimit = 1024;
        }
        return ((int) $this->getChildren()->count()) >= $this->childrenLimit;
    }
1218547
private function checkPages()
    {
        if (is_null($this->pageLimit)) {
            return false;
        }

        if (++$this->pageCounter > $this->pageLimit) {
            return true;
        }
        return false;
    }
1281563
public function validateMaxLength()
    {
        $val = $this->val();

        if ($val === null && $this->allowNull()) {
            return true;
        }

        $maxLength = $this->maxLength();
        if ($maxLength == 0) {
            return true;
        }

        if (is_string($val)) {
            $valid = (mb_strlen($val) <= $maxLength);
            if (!$valid) {
                $this->validator()->error('Maximum length error', 'maxLength');
            }
        } else {
            $valid = true;
            foreach ($val as $v) {
                $valid = (mb_strlen($v) <= $maxLength);
                if (!$valid) {
                    $this->validator()->error('Maximum length error', 'maxLength');
                    return $valid;
                }
            }
        }

        return $valid;
    }