Bug->Doc #78933 [Fbk->Opn]: gc_collect_cycles() may need a second pass when destructors are used

From: Date: Mon, 09 Dec 2019 13:50:20 +0000
Subject: Bug->Doc #78933 [Fbk->Opn]: gc_collect_cycles() may need a second pass when destructors are used
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17101@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78933&edit=1 ID: 78933 Updated by: requinix@php.net Reported by: requinix@php.net -Summary: Presence of a destructor affects garbage collection +Summary: gc_collect_cycles() may need a second pass when destructors are used -Status: Feedback +Status: Open -Type: Bug +Type: Documentation Problem Package: *General Issues Operating System: Any (Windows?) PHP Version: 7.4.0 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2019-12-09 08:40:46] nikic@php.net Related To: Bug #78930 ------------------------------------------------------------------------ [2019-12-09 07:56:25] nikic@php.net Assuming the destructor doesn't do anything to make the object non-GCable, I believe that two runs should be sufficient. > Or perhaps a new optional "bool $repeat = true" argument to do that automatically? In reference to the original issue with PDO SQLite: No, I don't think this makes sense. Generally, manual GC runs should not be necessary to influence program behavior. I think this is an indication that PDO needs a way to explicitly close a connection that does not require destroying the object. I believe this was rejected in the past "because you can just write unset($pdo)", but in the presence of circular references this just isn't reliable. ------------------------------------------------------------------------ [2019-12-08 22:12:54] requinix@php.net Yes it does. Could it ever need more than two? If so, that would suggest using it like while (gc_collect_cycles()); Or perhaps a new optional "bool $repeat = true" argument to do that automatically? ------------------------------------------------------------------------ [2019-12-08 22:05:32] nikic@php.net Classes with destructors may require two GC runs to be fully collected. Does it work if you repeat gc_collect_cycles() twice? ------------------------------------------------------------------------ [2019-12-08 21:56:37] requinix@php.net Related To: Bug #78930 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78933 -- Edit this bug report at https://bugs.php.net/bug.php?id=78933&edit=1

« previous php.doc.bugs (#17101) next »