Created
November 1, 2011 06:59
-
-
Save real34/1330072 to your computer and use it in GitHub Desktop.
PHP : A simple function to display the current memory usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @see http://fr2.php.net/manual/en/function.mb-convert-encoding.php#103300 | |
function memory_usage() { | |
$mem_usage = memory_get_usage(true); | |
if ($mem_usage < 1024) { | |
$mem_usage .= ' bytes'; | |
} elseif ($mem_usage < 1048576) { | |
$mem_usage = round($mem_usage/1024,2) . ' kilobytes'; | |
} else { | |
$mem_usage = round($mem_usage/1048576,2) . ' megabytes'; | |
} | |
return $mem_usage; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment