JProfiler/getMemory: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Get information about current memory usage.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<n... |
m removing red link to edit, no existant pages |
||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 54: | Line 54: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
| Line 69: | Line 69: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API15]] | |||
Revision as of 18:41, 12 May 2013
Description
Get information about current memory usage.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
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;
}
}
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />