Bug #80125 [Com]: CallbackFilterIterator is leaking memory
Edit report at https://bugs.php.net/bug.php?id=80125&edit=1
ID: 80125
Comment by: mvorisek at mvorisek dot cz
Reported by: mvorisek at mvorisek dot cz
Summary: CallbackFilterIterator is leaking memory
Status: Duplicate
Type: Bug
Package: Scripting Engine problem
Operating System: linux
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
Here is a solution using WeakReference:
https://3v4l.org/U3h2Q
I wonder if this can be fixed in php directly - using proper GCable solution or even with
WeakReference
Previous Comments:
------------------------------------------------------------------------
[2020-09-23 20:08:19] nikic@php.net
Duplicate of bug #65387.
------------------------------------------------------------------------
[2020-09-23 20:04:43] mvorisek at mvorisek dot cz
this is not working as well, Closure::bindTo is defined like "duplicate and bind", so you
must assign the result
https://3v4l.org/Ggt54
then the issue remains - CallbackFilterIterator is not GCed even if there is no reference to it, it
is a clear bug to me and it should be fixed
------------------------------------------------------------------------
[2020-09-23 16:45:14] kalle@php.net
Then create a closure, and pass it, clone + bindTo on assignment it to the scope which you want:
https://3v4l.org/gemWn
------------------------------------------------------------------------
[2020-09-23 16:27:29] mvorisek at mvorisek dot cz
No! The CallbackFilterIterator must be GCable like any other object.
I simplified the test script (to use bound function with simple condition), I can not use static and
I also mentioned this in the description. This is a clear bug to me.
------------------------------------------------------------------------
[2020-09-23 16:19:36] kalle@php.net
You should declare the closure as static and you will get the desired result:
https://3v4l.org/QPlkq
------------------------------------------------------------------------
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=80125
--
Edit this bug report at https://bugs.php.net/bug.php?id=80125&edit=1
Thread (7 messages)