check size of memory before exporting it to .php file -
i wrote php script index contents of site , stores in multi-dimensional arrays. export in memory, array, .php file include , access later.
how can check size of memory or size of memory associated variable i'm exporting before save file.
for example, if less 1gb, export. else, nothing , erase what's in memory associated variable $x.
how this?
try with:
memory_get_usage()
call function before , after create array, , take difference.
echo "at start we're using (in bytes): ", memory_get_usage() , "\n<br>"; ... array... echo "after, we're using (in bytes): ", memory_get_usage(),"\n<br>";
or
$before = memory_get_usage(); ... array ... $after = memory_get_usage(); echo round(($after-$before)/1024/1024, 2)." mb\n";
Comments
Post a Comment