API15:JProfiler/getMemory
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Get information about current memory usage.
Description:JProfiler/getMemory
Syntax
getMemory()
Returns
int The memory usage
Defined in
libraries/joomla/error/profiler.php
Importing
jimport( 'joomla.error.profiler' );
Source Body
function getMemory() { static $isWin; if (function_exists( 'memory_get_usage' )) { return memory_get_usage(); } else { // Determine if a windows server if (is_null( $isWin )) { $isWin = (substr(PHP_OS, 0, 3) == 'WIN'); } // Initialize variables $output = array(); $pid = getmypid(); if ($isWin) { // Windows workaround @exec( 'tasklist /FI "PID eq ' . $pid . '" /FO LIST', $output ); if (!isset($output[5])) { $output[5] = null; } return substr( $output[5], strpos( $output[5], ':' ) + 1 ); } else { @exec("ps -o rss -p $pid", $output); return $output[1] *1024; } } }
[Edit See Also] SeeAlso:JProfiler/getMemory
Examples
<CodeExamplesForm />
