Source for file function.memusage.php
Documentation is available at function.memusage.php
* smarty_function_memusage
// Tested on Win XP Pro SP2. Should work on Win 2003 Server too
// If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
if( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
if( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
exec( 'tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output );
$memusage = preg_replace( '/[\D]/', '', $output[5] ) * 1024;
// We now assume the OS is UNIX
// Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
// This should work on most UNIX systems
exec( "ps -eo%mem,rss,pid | grep $pid", $output );
// rss is given in 1024 byte units
$memusage = $output[1] * 1024;
$memusage = $memusage/ 1024;
$memusage= $memusage/ 1024;
$memusage= $memusage/ 1024;
|