Doc #78933 [Opn]: gc_collect_cycles() may need a second pass when destructors are used
| From: | nikic@php.net | Date: | Wed, 09 Jun 2021 12:54:13 +0000 |
| Subject: | Doc #78933 [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-18840@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: nikic@php.net
Reported by: requinix@php.net
Summary: gc_collect_cycles() may need a second pass when
destructors are used
Status: Open
Type: Documentation Problem
Package: *General Issues
Operating System: Any (Windows?)
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
For PHP 8.1, I have added an automatic GC re-run for destructed objects in https://github.com/php/php-src/commit/b58d74547f7700526b2d7e632032ed808abab442.
Previous Comments:
------------------------------------------------------------------------
[2021-06-09 10:36:27] cmb@php.net
Related To: Bug #81117
------------------------------------------------------------------------
[2019-12-09 16:11:58] cmb@php.net
> As far as I know, this is only possible to do on Windows since
> Linux is supposed to allow deleting files with open handles.
FWIW, as of PHP 7.3.0, files opened by the engine can also be
deleted on Windows if they have open handles. That doesn't apply
to SQLite3 databases, though.
------------------------------------------------------------------------
[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?
------------------------------------------------------------------------
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