Bug #81361 [Opn->Dup]: memory leak with anonymous function in an eval statement
| From: | nikic@php.net | Date: | Mon, 16 Aug 2021 10:21:19 +0000 |
| Subject: | Bug #81361 [Opn->Dup]: memory leak with anonymous function in an eval statement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235843@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81361&edit=1
ID: 81361
Updated by: nikic@php.net
Reported by: zelnaga at gmail dot com
Summary: memory leak with anonymous function in an eval
statement
-Status: Open
+Status: Duplicate
Type: Bug
Package: Performance problem
Operating System: any
PHP Version: 8.0.9
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #76982.
Previous Comments:
------------------------------------------------------------------------
[2021-08-14 22:36:30] zelnaga at gmail dot com
Description:
------------
eval('return function() {};') seems to create a memory leak.
If I replace eval('return function() {};'); with function() {}; there's no memory
leak but if I replace eval('return function() {};'); with $a = eval('return
function() {};'); unset($a); there is still. So it's like the eval() is what's
causing the issue.
Per https://3v4l.org/3p4sl apparently this code didn't
start leaking until PHP 7.4.
Test script:
---------------
<?php
while (true) {
eval('return function() {};');
gc_collect_cycles();
$new = memory_get_usage();
if (isset($old)) {
echo ($new - $old) . "\n";
}
$old = $new;
}
?>
Expected result:
----------------
I would expect this to output a bunch of 0's, one after the other.
Actual result:
--------------
432 is output over and over and over again, indicating that each new pass is consuming an additional
432 bytes than the last one.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81361&edit=1