Edit report at https://bugs.php.net/bug.php?id=55228&edit=1
ID: 55228 Comment by: cofyc dot jackson at gmail dot com Reported by: cofyc dot jackson at gmail dot com Summary: Objects cannot be collected if they extends some spl classes Status: Duplicate Type: Bug Package: SPL related Operating System: Mac OS X PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Can you fix ArrayObject/ArrayIterator classes like SPLObjectStorage in bug #53071? We use these two classes in production. This gc bug troubles us very much. Thanks in advance. Previous Comments: ------------------------------------------------------------------------ [2011-07-22 04:43:19] cataphr...@php.net Duplicate of bug #53803. ------------------------------------------------------------------------ [2011-07-18 07:31:08] cofyc dot jackson at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=55228&edit=1