Re: Leak Script
| From: | Andi Gutmans | Date: | Wed, 14 Jan 2004 19:36:55 +0000 |
| Subject: | Re: Leak Script | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7112@lists.php.net to get a copy of this message | ||
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 {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. Andipublic $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?