|
Posted by Jerry Stuckle on 04/21/07 03:22
ljb wrote:
> jstucklex@attglobal.net wrote:
>> ljb wrote:
>>>> ...
>>> 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.
>
> Just for discussion, is there a case where PHP can "detect when the
> resource is no longer being used" other than when the variable referencing
> the resource goes out of scope? I believe you that there is, but I can't
> think of any.
>
> Also are you saying that if the resource is a local variable in a function,
> and the function returns, there can be a delay before the resource is
> cleaned up (for example, a database connection is closed)?
I was referring specifically to when the page completes. Cleanup may
not be done immediately. I don't know for sure about when a function exits.
And no, there is no way for PHP to predict if a resource still being
referenced by a variable is going to be used or not. I'd love it if
they could - I'd use that to write a program to predict the lottery
numbers :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|