On Tue, 2003-10-07 at 22:44, Gerard Samuel wrote:
> The question is what happens to local variables when the code leaves a
> function/method
> as far as memory is concerned.
> Does it *silently* unset (free the allocated memory) the local
> variables, or does it make sense to hardcode
> unset() to garbage these local variables?
> Thanks
>
> function foo()
> {
> $bar = 'some large value';
> unset($bar);
> }
> ---------
> function foo()
> {
> $bar = 'some large value';
> }
AFAIK when the reference count (both explicit and implicit due to
copying optimizations) hits 0, the variable is deleted. Thus within a
function if you declare the variable within the function and it isn't
referenced anywhere else, then it is destroyed when the function's
context is destroyed.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php