Bug #52902 [Opn->Bgs]: Recursive References Leak Memory
| From: | cataphract@php.net | Date: | Tue, 21 Sep 2010 19:32:11 +0000 |
| Subject: | Bug #52902 [Opn->Bgs]: Recursive References Leak Memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154540@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52902&edit=1
ID: 52902
Updated by: cataphract@php.net
Reported by: jcampbell at remindermedia dot com
Summary: Recursive References Leak Memory
-Status: Open
+Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: Fedora 12
PHP Version: 5.3.3
Block user comment: N
New Comment:
How is this leaking memory? Only <2MB for 2 million objects (A+B)? An
object takes more than 1 byte...
If you make the loop instantiate 10 times more objects, you see memory
usage remains constant, so the garbage collection mechanism is
definitely working here.
Previous Comments:
------------------------------------------------------------------------
[2010-09-21 21:20:05] jcampbell at remindermedia dot com
Description:
------------
The behavior originally reported in #33595 still exists, namely,
"Objects with recursive references leak memory."
Test script:
---------------
class A {
function __construct () {
$this->b = new B($this);
}
}
class B {
function __construct ($parent = NULL) {
$this->parent = $parent;
}
}
echo memory_get_usage() . "\n";
for ($i = 0 ; $i < 1000000 ; $i++) {
$a = new A();
}
echo memory_get_usage() . "\n";
Expected result:
----------------
Memory usage should remain relatively constant. For example, if you
change the one line to:
"$this->parent = clone $parent;"
Then the output is:
632216
632392
Actual result:
--------------
Memory usage increases with each newly instantiated object.
Actual output:
631976
1756792
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52902&edit=1