Voting

: two minus two?
(Example: nine)

The Note You're Voting On

vesa dot kivisto at nepton dot fi
20 years ago
[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
// Please note that you'll need the pslist.exe utility from http://www.sysinternals.com/Utilities/PsTools.html
// This is because win/2000 itself does not provide a task list utility.
//
function getMemoryUsage() {

// try to use PHP build in function
if( function_exists('memory_get_usage') ) {
return
memory_get_usage();
}

// Try to get Windows memory usage via pslist command
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';

}


// No memory functionality available at all
return '<b style="color: red;">no value</b>';

}
?>

<< Back to user notes page

To Top