2017年3月2日 星期四

How to determine the memory footprint (size) of a variable?

// return bytes
function getVariableSize ( $foo ) 
{
    $tmpfile = "temp-" . microtime(true) . ".txt";
    file_put_contents($tmpfile, $foo);
    $size = filesize($tmpfile);
    unlink($tmpfile);
    return $size;
}

from : http://stackoverflow.com/questions/2192657/how-to-determine-the-memory-footprint-size-of-a-variable

沒有留言:

wibiya widget