[EDIT by danbrown AT php DOT net: This function will only extend Windows versions of PHP where the server has the required third-party software.]
I was unable to get the previous examples working properly and created code which works at least for me. Enjoy!
<?php
function getMemoryUsage() {
if( function_exists('memory_get_usage') ) {
return memory_get_usage();
}
if ( substr(PHP_OS,0,3) == 'WIN') {
$resultRow = 8;
$resultRowItemStartPosition = 34;
$resultRowItemLength = 8;
$output = array();
exec('pslist -m ' . getmypid() , $output);
return trim(substr($output[$resultRow], $resultRowItemStartPosition, $resultRowItemLength)) . ' KB';
}
return '<b style="color: red;">no value</b>';
}
?>