ID: 33595
Updated by: [EMAIL PROTECTED]
Reported By: rodricg at sellingsource dot com
Status: Assigned
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.0.4
Assigned To: dmitry
New Comment:
Yes. This is different bug. However it is not very critical (as bug
#33487 too), because all memory is freed on request shutdown.
I don't know how to implement support for circular data structures
freeing without significant performance lose.
Previous Comments:
------------------------------------------------------------------------
[2005-07-07 14:11:47] [EMAIL PROTECTED]
Dmitry, is it different or not?
------------------------------------------------------------------------
[2005-07-07 03:49:52] rodricg at sellingsource dot com
Distinctly different than bug #33487 this only occurs when the object
contains a recursive reference. Add
echo number_format(memory_get_usage());
to the end of the script and you get 346,360,656. Then comment out
$this->parent = $parent and run again to get 53,832. I suspect the
internal reference is not properly invalidated upon the destruction of
class A. This would keep the ref count > 0 and foil garbage
collection. Unless I am missing something....
------------------------------------------------------------------------
[2005-07-07 01:03:23] [EMAIL PROTECTED]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
See bug #33487.
------------------------------------------------------------------------
[2005-07-06 23:44:25] rodricg at sellingsource dot com
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 this bug report at http://bugs.php.net/?id=33595&edit=1