ID: 45225
Updated by: [EMAIL PROTECTED]
Reported By: vituko at gmail dot com
Status: Bogus
Bug Type: Class/Object related
Operating System: Lenny
PHP Version: 5.2.6
New Comment:
Cyclic references can't be free'd until request end time due to the
fact there is no garbage collector in PHP. There is one in PHP 5.3 that
should deal with this as expected.
Previous Comments:
------------------------------------------------------------------------
[2008-06-10 14:54:05] vituko at gmail dot com
Ok, I've always worked with crossed references, what's wrong with them?
It's forbiden in php? I think it's a huge limitation, I would have to do
garbage collection myself and I only have debug_zval_dump : it's really
not very usefull but for debugging purpouses. And I have to choose
between true (&) references and "php" references because if both are
used, refcount is no more significatif... Can you give me an advice?
------------------------------------------------------------------------
[2008-06-10 10:54:39] [EMAIL PROTECTED]
You've created a cyclic reference and they can't be destroyed until the
script has ended.
------------------------------------------------------------------------
[2008-06-10 05:04:46] vituko at gmail dot com
Description:
------------
Garbage collection works in an unexpected way for me,
when there're crossed references. I discovered it working with large
databases, Apache crashes sometimes : the thread hangs and
after /etc/init.d/apache2 restart, it continues working.
Another thing : the only way to get track of references is
debug_zval_dump (of course it can be done manually) and huge strings
must be parsed. Further, when mixing true (&) and "php" references
it's no more possible... or is it?
Only a tought...
Thanks
Reproduce code:
---------------
class a {
public function __destruct() {
echo 'destr<br>' ;
}
}
$a = new a ;
$a -> v = new a ;
$a -> w = new a ;
$a -> v -> w = $a -> w ;
$a -> w -> v = $a -> v ;
unset ($a) ;
echo 'fin<br>' ;
exit ;
Expected result:
----------------
destr
destr
destr
fin
Actual result:
--------------
destr
fin
destr
destr
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45225&edit=1