|
Posted by Jerry Stuckle on 04/20/07 02:07
ljb wrote:
> andre@webkr.de wrote:
>> Hi,
>>
>> is there a difference between imagedestroy($ih) and unset($ih)?
>>
>> The same with other similar functions like closedir, mysql_close,
>> curl_close, mysql_free_result, etc.
>>
>> And by the way... will the garbage collector even detect an "implicit
>> unset" when a resource is used for the last time?
>
> In the case of GD, I think imagedestroy does nothing more than unset. But
> you probably should not assume that in general. If the resource is properly
> implemented, then yes unsetting it should do all the necessary cleanup.
>
> The garbage collector does not detect when a resource is used for the last
> time. It does detect when it goes out of scope. For example, a resource
> variable local to a function ... when the function returns, the resource
> should be cleaned up.
One correction - the gc eventually detects when the resource is no
longer being used. But such detection is almost always not immediate,
and may in fact take quite some time.
It's much better to destroy the resources when you're done with them and
not leave it up to the gc. Doing the latter is just plain sloppy, lazy
or both.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|