if (preg_match("#--verbose#", implode(" ", $argv))) { $GLOBALS["VERBOSE"] = true; } if (preg_match("#--force#", implode(" ", $argv))) { $GLOBALS["FORCE"] = true; } if (!Build_pid_func(__FILE__, "MAIN")) { Myevents(basename(__FILE__) . ":Already executed.. aborting the process"); die; } if ($argv[1] == "--loadavg") { loadavg(); exit; } if ($argv[1] == "--mem") { loadmem(); exit; } if ($argv[1] == "--cpu") { loadcpu(); exit; } checkProcess1(); function checkProcess1() { $unix = new unix(); $pid = $unix->PIDOF_PATTERN("bin/process1"); if ($pid < 5) { return null; } $process1 = $unix->PROCCESS_TIME_MIN($pid);
//server-syncronize-64.png if(preg_match("#--verbose#",implode(" ",$argv))){$GLOBALS["VERBOSE"]=true;} if(preg_match("#--force#",implode(" ",$argv))){$GLOBALS["FORCE"]=true;} $unix=new unix(); $pidfile="/etc/artica-postfix/".basename(__FILE__)."pid"; $currentpid=trim(@file_get_contents($pidefile)); if($unix->process_exists($currentpid)){die();} @file_put_contents($pidfile,getmypid()); if($argv[1]=="--loadavg"){loadavg();exit;} if($argv[1]=="--mem"){loadmem();exit;} if($argv[1]=="--cpu"){loadcpu();exit;} if($argv[1]=="--queues"){ParseLoadQeues();exit;} checkProcess1(); function checkProcess1(){ $unix=new unix(); $pid=$unix->PIDOF_PATTERN("bin/process1"); if($pid<5){return null;} $process1=$unix->PROCCESS_TIME_MIN($pid); $mem=$unix->PROCESS_MEMORY($pid); Myevents("process1: $pid ($process1 mn) memory:$mem Mb",__FUNCTION__);
<?php // This is only an example, the numbers below will // differ depending on your system for ($i = 1; $i < 100; $i++) { //echo "used memory is " . memory_get_usage() . "<br/>"; $a = loadmem($i); //echo "used memory after allocating ".$i."m is " . memory_get_usage() . "<br/>"; // 57960 //echo "used memory after unsetting allocated memory is " . memory_get_usage() . "<br/>"; // 36744 echo "You have allocated " . $i . "M (" . memory_get_usage() . ") memory in this php script" . "<br />"; unset($a); } function loadmem($howmuchmeg) { $a = str_repeat("0", $howmuchmeg * 1024 * 1024); // alocating 10 chars times million chars return $a; } ?>