Bug #76982 [Opn->Ver]: memory leak declaring closure in included file
Edit report at https://bugs.php.net/bug.php?id=76982&edit=1
ID: 76982
Updated by: cmb@php.net
Reported by: ryan dot brothers at gmail dot com
Summary: memory leak declaring closure in included file
-Status: Open
+Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.2.10
Block user comment: N
Private report: N
New Comment:
This also happens on current master. It works fine if file2.php
is inlined. Neither a debug build nor valgrind
(ZEND_DONT_UNLOAD_MODULES=1 USE_ZEND_ALLOC=0) report a memory
leak, though.
Previous Comments:
------------------------------------------------------------------------
[2018-10-08 02:40:59] ryan dot brothers at gmail dot com
Description:
------------
I am running PHP 7.2.10 on CentOS 7. If I run the below script file1.php, the memory usage
gradually increases until it hits the memory limit. The memory usage should remain relatively
constant. It's related to declaring the closure in file2.php, as if I remove the closure, then
the memory usage stays constant.
Also, the memory usage stays constant in PHP 5.6, so the issue is perhaps only in PHP 7 and later.
Test script:
---------------
file1.php
<?php
for ($i = 0; $i < 1000000; $i++)
{
echo $i.' - '.number_format(memory_get_usage())."\n";
require('file2.php');
}
file2.php:
<?php
$test_function = function()
{
};
Expected result:
----------------
Memory usage stays constant.
Actual result:
--------------
Memory usage increases until it hits the memory limit.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76982&edit=1
Thread (10 messages)