Bug #76982 [Com]: memory leak declaring closure in included file
| From: | ryan dot brothers at gmail dot com | Date: | Tue, 09 Oct 2018 13:21:19 +0000 |
| Subject: | Bug #76982 [Com]: memory leak declaring closure in included file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217483@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76982&edit=1
ID: 76982
Comment by: ryan dot brothers at gmail dot com
Reported by: ryan dot brothers at gmail dot com
Summary: memory leak declaring closure in included file
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:
Thanks for confirming. If it helps, the same problem also happens if you put "return;" as
the first line of file2.php like the below, so it seems related to compiling perhaps, rather than
executing.
file2.php:
<?php
return;
$test_function = function()
{
};
Previous Comments:
------------------------------------------------------------------------
[2018-10-09 12:07:45] cmb@php.net
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.
------------------------------------------------------------------------
[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