ID:               33595
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rodricg at sellingsource dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: *
 PHP Version:      6CVS-2005-08-02
 Assigned To:      dmitry
 New Comment:

Fixed with GC patch in CVS HEAD and PHP_5_3.


Previous Comments:
------------------------------------------------------------------------

[2007-11-22 14:48:30] shez at starfangled dot net

Hi,

Does anybody have an easy way to trace _what_ objects have been 
leaked due to circular references?  I've had couple of cases in 
large code bases that I've had to trace by the old binary search 
algorithm (you know the one, remove half of the code, test, etc ;)

Cheers!
Shez

------------------------------------------------------------------------

[2007-08-04 00:40:21] zwacks10 at yahoo dot com

<?php
class A {
    function __construct () {
        $this->b = new B($this);
    }
}

class B {
    function __construct ($parent = NULL) {
        $this->parent = $parent;
    }
}

for ($i = 0 ; $i < 1000000 ; $i++) {
    $a = new A();
    unset($a);
}

echo number_format(memory_get_usage());
?>


Try this code. you will also avoid the memory leak...

This forum really helps me to solve this problem. You gave me an idea
to avoid this bugs. i really appreciate it. Thanks a lot guys.

------------------------------------------------------------------------

[2007-08-03 09:37:44] zwacks10 at yahoo dot com

This Forum is help full thanks to you guys.

------------------------------------------------------------------------

[2007-05-25 19:50:39] wckits at rit dot edu

Any suggestion to call the destructor explicitly is misguided at best
and dangerous at worst. You may have another reference to that object
somewhere, and it will end up being a reference to a destructed object.

------------------------------------------------------------------------

[2007-01-24 13:53:46] taneli at crasman dot fi

It shouldn't be a known "got cha". 

I just wrote a backgrounded daemon using PHP and I had to instate a
checker process just to restart the process any time it dies (because it
leaks memory about 30 megs per "daemon loop", because of references).

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/33595

-- 
Edit this bug report at http://bugs.php.net/?id=33595&edit=1

Reply via email to