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

 ID:                 33595
 Comment by:         a at a dot com
 Reported by:        rodricg at sellingsource dot com
 Summary:            recursive references leak memory
 Status:             Closed
 Type:               Bug
 Package:            Class/Object related
 Operating System:   *
 PHP Version:        6CVS-2005-08-02
 Assigned To:        dmitry
 Block user comment: N

 New Comment:

Fix in PHP 5.3.


Previous Comments:
------------------------------------------------------------------------
[2008-01-29 11:35:05] dmi...@php.net

Fixed with GC patch in CVS HEAD and PHP_5_3.

------------------------------------------------------------------------
[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.

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


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/bug.php?id=33595


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

Reply via email to