/** * getMemoryUsage * * @access public * @param bool $aPrint * @return rettype return */ protected static function getMemoryUsage() { if (!function_exists('memory_get_usage')) { if (substr(PHP_OS, 0, 3) == 'WIN') { $output = array(); exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output); $memory = preg_replace('/[\\D]/', '', $output[5]) * 1024; } else { $pid = getmypid(); exec("ps -eo%mem,rss,pid | grep {$pid}", $output); $output = explode(" ", $output[0]); $memory = @$output[1] * 1024; } } else { $memory = memory_get_usage(); } $memorySection = $memory - self::$memory; $memoryTotal = sprintf("%08s", $memory); $memorySection = sprintf("%08s", $memorySection); self::$memory = $memory; return array($memoryTotal, $memorySection); }