|
Posted by Jerry Stuckle on 04/20/07 12:33
gosha bine wrote:
> On 20.04.2007 02:17 André Hänsel wrote:
>> Hi,
>>
>> is there a difference between imagedestroy($ih) and unset($ih)?
>
> No. unset() checks if a variable is referenced elsewhere and if not,
> destroys the variable and its value immediately. This is called
> "reference counting".
>
>>
>> The same with other similar functions like closedir, mysql_close,
>> curl_close, mysql_free_result, etc.
>
> Yes, if an extension author took care of registering his destructor in
> zend core.
>
>>
>> And by the way... will the garbage collector even detect an "implicit
>> unset" when a resource is used for the last time?
>
> php doesn't use "garbage collector", memory is reclaimed immediately as
> it becomes inaccesible.
>
>>
>> Regards,
>> André
>>
>
>
Andre,
Not completely true.
Yes, memory is reclaimed immediately when you unset the resource. But if
you don't unset it before the end of the page, there may be a delay
before PHP gets around to cleaning things up. It doesn't necessarily do
it immediately.
Also, there is a garbage collector for sessions to clean up old session
files. But that's different.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|