Memory management in PHP
Date: 03/28/05
(PHP Community) Keywords: php
I have a question regarding memory management in PHP. I have not been able to find my answer in the documentation at php.net, in books, or searching on the Internet.
My question is simple: how is memory management handled in PHP? Is there garbage collection? Are we supposed to explicitly handle freeing of memory? Or is it neither, and it's just assumed that scripts are small and all memory is freed upon completion of the script? The latter case would seem to be a dangerous assumption should someone write a complex PHP program, but practically speaking it's probably fine for how PHP is generally used.
I did read one reference that implied that unset() would remove the variable/object from memory, but I also saw a user comment that implied that it didn't actually free the memory. The documentation at php.net doesn't seem to say one way or the other.
Practically, the answer to this question isn't going to impact what I'm doing. As long as the memory is freed at the completion of the script, I'll be fine. But I'm curious what the answer to this question is and I can't find the answer after having done due diligence. Can anyone help? Thanks!
Source: http://www.livejournal.com/community/php/278091.html