|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-26 12:10 UTC] nikic@php.net
-Status: Open
+Status: Wont fix
-Package: Feature/Change Request
+Package: *General Issues
[2016-03-26 12:10 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 10:00:01 2025 UTC |
Description: ------------ I have a suggestion for circular reference problem, already mentioned in report 33595 ... I realize that it is already fix in cvs with David Wang's patch, but maybe this would also be good to have ? Reproduce code: --------------- for example: class foo { function __construct () { $this->bar = new bar($this); } function __refcount ($count) { if ($count <= 1) unset($this->bar); } } class bar { function __construct ($foo = null) { $this->foo = $foo; } } $object = new foo(); unset($object); // $object->__refcount(1); // one reference left Expected result: ---------------- now, this would create a circular reference when creating foo, and I suggest that when a reference to an object is removed or added, and refcount changes, a __refcount method is called, that way, in some cases when object knows how many circular references it has, can unset them and free the memory... in this example, foo knows that it has exactly 1 reference from bar, and if count is greater then 1, it is still needed... I know that with this, David Wang's patch may still be needed for objects that don't know the exact refcount, but this may have some good effect on performance ? rather then calculating circular references ?