This is a function that should work for both Windows XP/2003 and most distrabutions of UNIX and Mac OS X.
<?php
if( !function_exists('memory_get_usage') )
{
function memory_get_usage()
{
if ( substr(PHP_OS,0,3) == 'WIN')
{
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);
$output = explode(" ", $output[0]);
return $output[1] * 1024;
}
}
}
?>