From: Matthias Schmidt Date: Sat, 4 Oct 2014 10:36:47 +0000 (+0200) Subject: Add FileUtil::checkMemoryLimit() X-Git-Tag: 2.1.0_Alpha_1~279 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4a99533b4bab09c35ebd48d3f6bc9f23e1101543;p=GitHub%2FWoltLab%2FWCF.git Add FileUtil::checkMemoryLimit() --- diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index c5643ebb5d..6fb3d322c8 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -604,5 +604,15 @@ final class FileUtil { return self::$memoryLimit; } + /** + * Returns true if the given amount of memory is available. + * + * @param integer $neededMemory + * @return boolean + */ + public static function checkMemoryLimit($neededMemory) { + return self::getMemoryLimit() == -1 || self::getMemoryLimit() > (memory_get_usage() + $neededMemory); + } + private function __construct() { } }