JProfiler/getMemory: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 50: | Line 50: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=getMemory | category=getMemory | ||
category=JProfiler | category=JProfiler | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 01:59, 25 March 2017
Description
Get information about current memory usage.
Syntax
getMemory()
Returns
int The memory usage
Defined in
libraries/joomla/error/profiler.php
Importing
jimport( 'joomla.error.profiler' );
Source Body
public function getMemory()
{
if (function_exists('memory_get_usage')) {
return memory_get_usage();
}
else
{
// Initialise variables.
$output = array();
$pid = getmypid();
if ($this->_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;
}
}
}
Examples
Code Examples