Re: New destructors implementation
| From: | Stephane Drouard | Date: | Mon, 09 Feb 2004 18:35:55 +0000 |
| Subject: | Re: New destructors implementation | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7678@lists.php.net to get a copy of this message | ||
== Quote from Eric Daspet (ganfset-php@dreams4net.com)'s article
> Be carreful, this does not resolve all things :
>
> $source1 = new stdClass ;
> $source2 = new stdClass ;
> $source3 = new stdClass ;
> $refLevel1 = new stdClass ;
> $refLevel2 = new stdClass ;
>
> $source1->ref = $refLevel1 ;
> $source2->ref = $refLevel1 ;
> $source3->ref = $refLevel1 ;
>
> $refLevel1->ref = $refLevel2 ;
>
>
> We have :
> refcount of 1 : $source1, $source2 and $source3
> refcount of 2 : $refLevel2 ;
> refcount of 4 : $refLevel1 ;
>
> $refLevel1 as a refcount of 4 but should be destroyed before $refLevel2
> (which has a refcount of 2).
> This is NOT the same as destroy refcounts of 1, then refcount of 2, etc.
Hum... good point for you ;-)
I was in a hurry to test your case within a function (local variables), and the objects were
destroyed as expected.
It's a bit frustrating to know that PHP perfectly handles destruction mechanism for local
variables, but not for global variables...
Stephane