How would you go about ensuring the memory is not exhausted when running a script ? I have a script, which to make it basic ... reads values from files, I create an array of values per file then with a foreach insert values into a table, I have added a line to echo the memory use after each array is done (after insert is done and the foreach is complete for the file) with: -> echo "Mem SQL: ".memory_get_usage() . "\n"; It gave me this result below: Mem SQL: 8341312 Mem SQL: 8461856 Mem SQL: 8693440 Mem SQL: 9327008 Mem SQL: 9798952 Mem SQL: 10238392 Mem SQL: 10604776 As can be seen the mem usage simply grows, I have added a line after each iteration of the foreach is complete to unset the vars and array ... thinking this would basically clear up the allocated memmory used by the array ... and it would start at 0 again for the next array looped, but obviously this is not quite the answer. The question is then how do you "clear" memmory then ?