/**
  * Gets the current memory limit.
  *
  * @return int
  */
 public static function getMemoryLimit()
 {
     if (self::$_memoryLimit === null) {
         $curLimit = @ini_get('memory_limit');
         if ($curLimit === false) {
             // reading failed, so we have to treat it as unlimited - unlikely to be able to change anyway
             $curLimit = -1;
         } else {
             switch (substr($curLimit, -1)) {
                 case 'g':
                 case 'G':
                     $curLimit *= 1024;
                     // fall through
                 // fall through
                 case 'm':
                 case 'M':
                     $curLimit *= 1024;
                     // fall through
                 // fall through
                 case 'k':
                 case 'K':
                     $curLimit *= 1024;
             }
         }
         self::$_memoryLimit = intval($curLimit);
     }
     return self::$_memoryLimit;
 }