Created
November 9, 2021 10:22
-
-
Save sr2ds/f74e79facef3f83722f8d8c8c7c5b8e0 to your computer and use it in GitHub Desktop.
Check memory usage PHP script
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 | |
// https://www.php.net/manual/en/function.memory-get-usage.php#96280 | |
function convert($size) | |
{ | |
$unit=array('b','kb','mb','gb','tb','pb'); | |
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; | |
} | |
echo convert(memory_get_usage(true)); // 123 kb | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment