Bug #55228 [NEW]: Objects cannot be collected if they extends some spl classes
| From: | cofyc dot jackson at gmail dot com | Date: | Mon, 18 Jul 2011 11:31:08 +0000 |
| Subject: | Bug #55228 [NEW]: Objects cannot be collected if they extends some spl classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-161956@lists.php.net to get a copy of this message | ||
From:
Operating system: Mac OS X
PHP version: 5.3.6
Package: SPL related
Bug Type: Bug
Bug description:Objects cannot be collected if they extends some spl classes
Description:
------------
If objects' classes extends ArrayIterator/ArrayObject, and recursively
refer to
each other, they will not be garbage collected.
I tried reproduction code in https://bugs.php.net/bug.php?id=33595,
modified A to
extend ArrayIterator, B to extend ArrayObject.
And is there a way to work around it currently?
Test script:
---------------
<?php
class A extends ArrayIterator {
function __construct () {
$this->b = new B($this);
}
}
class B extends ArrayObject {
function __construct ($parent = NULL) {
$this->parent = $parent;
}
}
for ($i = 0 ; $i < 1000000 ; $i++) {
$a = new A();
printf("gc: %d, %f\n", gc_collect_cycles(),
memory_get_usage()/1024/1024);
}
--
Edit bug report at https://bugs.php.net/bug.php?id=55228&edit=1
--
Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55228&r=trysnapshot52
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55228&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55228&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55228&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55228&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55228&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55228&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55228&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55228&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55228&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55228&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55228&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55228&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55228&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55228&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55228&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55228&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55228&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55228&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55228&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55228&r=mysqlcfg
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55228&r=trysnapshot54