#33595 [NEW]: Memory leak

From: Date: Wed, 06 Jul 2005 21:44:26 +0000
Subject: #33595 [NEW]: Memory leak
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81498@lists.php.net to get a copy of this message
From:             rodricg at sellingsource dot com
Operating system: Linux
PHP version:      5.0.4
PHP Bug Type:     Class/Object related
Bug description:  Memory leak

Description:
------------
Objects with recursive references leak memory. 
PHP 5.1.0b2 exhibits the same behavior. 

Reproduce code:
---------------
<?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();
}
?>

Expected result:
----------------
Memory usage should remain constant. 

Actual result:
--------------
Memory usage quickly increases to consume several hundred 
megabytes. 

-- 
Edit bug report at http://bugs.php.net/?id=33595&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33595&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33595&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33595&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33595&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33595&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33595&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33595&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33595&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33595&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33595&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=33595&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=33595&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33595&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33595&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33595&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33595&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33595&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33595&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33595&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33595&r=mysqlcfg


Thread (22 messages)

« previous php.bugs (#81498) next »