Skip to content

Instantly share code, notes, and snippets.

@cyrildewit
Forked from mehdichaouch/memory_usage.php
Created January 8, 2022 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrildewit/4c27a75275eebf5485bc50b08dff44f1 to your computer and use it in GitHub Desktop.
Save cyrildewit/4c27a75275eebf5485bc50b08dff44f1 to your computer and use it in GitHub Desktop.
PHP Snippet to get human readable memory usage
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
convert(memory_get_usage());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment