Beispiel #1
0
 /**
  * getMemoryUsage
  *
  * @return  array
  */
 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("%08d", $_memory);
     $_memorySection = sprintf("%08d", $_memorySection);
     self::$_memory = $_memory;
     return array($_memoryTotal, $_memorySection);
 }