- 论坛徽章:
- 0
|
- if( !function_exists('memory_get_usage') ) {
- function memory_get_usage() {
- if ( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
- $output = array();
- exec( 'tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output );
- return preg_replace( '/[\D]/', '', $output[5] ) * 1024;
- }
- } else {
- $pid = getmypid();
- exec("ps -eo%mem,rss,pid | grep $pid", $output); // Comment this line for MAC OS X 10.4 (Intel)
- $output = explode(" ", $output[0]);
- return $output[1] * 1024;
- }
- }
- }
复制代码
我用这个的时候和用系统自带的 返回值不太一样
另外我还不确定用得到系统进程使用的内存是否合适,我需要的是允许php程序使用的内存大小限制,就是php程序中 $x 这个变量能用的多大的内存 |
|