Entry
Is the memory used by variables freed automatically during script execution?
Do I need to explicitly free the memory used by variables in PHP scripts?
Jul 3rd, 1999 20:02
Nathan Wallace, Zeev Suraski
You shouldn't worry about PHP variables consuming memory, except for
very specific cases when you use indirect reference to variable names
and reference different variables in every iteration (extremely rare).
If you use the same variables all throughout the loop (which is almost
always the case), only the memory necessary to store the current value
of the variable(s) remains allocated. The old values are freed and do
not consume memory.