protected static function get_memory_limit() { if (self::$memory_limit === null) { $memory_limit = ini_get('memory_limit'); if (preg_match('/^(\\d+)(.)$/', $memory_limit, $matches)) { if ($matches[2] == 'M') { $memory_limit = $matches[1] * 1024 * 1024; // nnn_m -> nnn MB } else { if ($matches[2] == 'K') { $memory_limit = $matches[1] * 1024; // nnn_k -> nnn KB } } } self::$memory_limit = $memory_limit; } return self::$memory_limit; }