Bug #80125 [Com]: CallbackFilterIterator is leaking memory

From: Date: Tue, 29 Sep 2020 10:00:20 +0000
Subject: Bug #80125 [Com]: CallbackFilterIterator is leaking memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229262@lists.php.net to get a copy of this message
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)

« previous php.bugs (#229262) next »