At 10:03 AM 1/14/2004 -0500, Sterling Hughes wrote:
> > Looks like a circular reference to me. It's supposed to leak :)
> >
>
>Yep - but shouldn't object destruction be forced before the memory
>manager cleans it up. The example could rather be put as:
>
><?php
>class InstanceContainer {
> public $value;
>
> function __construct() {
> $this->value = new GenericObject($this);
> }
>
> function __destruct() {
> print "Called\n";
> }
>}
>
>class GenericObject {
> public $internal;
>
> function __construct($instance) {
> $this->internal = $instance;
> }
>}
>
>$o = new InstanceContainer();
>?>
>
>As you can predict, __destruct() won't be called. Shouldn't objects be
>unmercifully cleaned up before we rely on the memory manager to burn the
>leftovers?
Not really. The reason is that say the two object's destructors depend on
each other then you're going to be in a mess.
There's no way of executing that in the right order. We are discussing with
Marcus a patch he wrote which will basically warn you that this has
happened so that you can fix your code.
The patch isn't in the engine yet because I want to find a nicer way of
implementing it.
Andi