From 4a99533b4bab09c35ebd48d3f6bc9f23e1101543 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 4 Oct 2014 12:36:47 +0200 Subject: [PATCH] Add FileUtil::checkMemoryLimit() --- wcfsetup/install/files/lib/util/FileUtil.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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() { } } -- 2.20.1