Bug #80125 [NEW]: CallbackFilterIterator is leaking memory
From: mvorisek at mvorisek dot cz
Operating system: linux
PHP version: 7.4.10
Package: Scripting Engine problem
Bug Type: Bug
Bug description:CallbackFilterIterator is leaking memory
Description:
------------
see test script, explicit GC does not help
the issues seems present when the given callback to
CallbackFilterIterator is bound (eg. not static)
https://3v4l.org/UpmHK
Test script:
---------------
class IteratorWithFilter
{
public $generator;
public function __construct(array $data)
{
$this->generator = new \ArrayIterator($data);
}
public function filter()
{
$this->generator = new \CallbackFilterIterator($this->generator,
function ($row) {
return true;
});
return $this;
}
}
function createIterator() {
$iter = new IteratorWithFilter([['a'], ['b']]);
return $iter->filter();
}
for ($i = 0; $i < 50 * 1000; $i++) {
createIterator();
if (($i % 1000) === 0) {
// gc_collect_cycles(); // explicit GC does not help...
echo round(memory_get_usage() / (1024 * 1024), 3) . " MiB\n";
}
}
Expected result:
----------------
reported memory usage should stay below 1 MiB
Actual result:
--------------
0.375 MiB
1.719 MiB
3.071 MiB
4.36 MiB
5.774 MiB
7.064 MiB
8.353 MiB
9.892 MiB
...
--
Edit bug report at https://bugs.php.net/bug.php?id=80125&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80125&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80125&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80125&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80125&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80125&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80125&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80125&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80125&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80125&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80125&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80125&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80125&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80125&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80125&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80125&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80125&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80125&r=mysqlcfg
Thread (7 messages)
- mvorisek at mvorisek dot cz