Add FileUtil::checkMemoryLimit()
authorMatthias Schmidt <gravatronics@live.com>
Sat, 4 Oct 2014 10:36:47 +0000 (12:36 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 4 Oct 2014 10:36:47 +0000 (12:36 +0200)
wcfsetup/install/files/lib/util/FileUtil.class.php

index c5643ebb5d7c8a544b183b49eb396ff315204802..6fb3d322c847e795ef74e66ba74c2d8a1502b04c 100644 (file)
@@ -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() { }
 }