$m = memory_get_usage(); echo $m; require_once(‘include/entryPoint.php‘); // for ($i=0; $i < 500000; $i++){ // $rliBean[] = BeanFactory::newBean(‘ibm_RevenueLineItems‘); // } if ($argc == 1) { for ($i=0; $i < 5; $i++) { exec(‘php -d display_errors ‘ . $argv[0] . ‘ ‘ . $i , $output, $return); echo $output; } } elseif (isset($argv[1])) { for ($i=0; $i < 50000; $i++) { $rliBean[] = BeanFactory::newBean(‘ibm_RevenueLineItems‘); // 消耗内存的代码 } $am = memory_get_usage(); //echo PHP_EOL; //echo $am; echo PHP_EOL; echo $am - $m; }
备忘,用exec函数做对文件的递归调用,防止单次执行内存消耗过大导致内存泄漏