-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested CallbackFilterIterator
is leaking memory
#7958
Comments
Doesn't seem like this is caused by afab9eb. In fact, it fixes the second iteration in your example, which also leaked. Here's a somewhat condensed example: class Action
{
public \Iterator $iterator;
public function __construct(array $data)
{
$this->iterator = new ArrayIterator($data);
echo '-- c ' . spl_object_id($this) . "\n";
}
public function __destruct()
{
echo '-- d ' . spl_object_id($this) . "\n";
}
public function filter()
{
$this->iterator = new \CallbackFilterIterator($this->iterator, fn() => true);
$this->iterator->rewind();
}
}
$action = new Action(['a', 'b']);
$action->filter();
$action->filter();
print_r(iterator_to_array($action->iterator));
$action = null;
gc_collect_cycles();
It's caused by the reference to |
Yes, it seems ref count is not properly decremented during GC cycle when Can you please mark this issue as verified and do you think it can be fixed in PHP v8.0 or at least v8.1? |
LimitIterator
is not GCableCallbackFilterIterator
is leaking memory
We implement `zend_object_iterator_funcs.get_gc` for user iterators to avoid the memory leak.
* PHP-8.1: Fix GH-7958: Nested CallbackFilterIterator is leaking memory
Description
The following code:
https://3v4l.org/3nIOH
https://3v4l.org/YQIVJ/rfc#vgit.master
is expected to output:
PHP Version
8.0.14, 8.1.1, master (all tested)
Operating System
linux
The text was updated successfully, but these errors were encountered: