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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -