Bug #76982 [NEW]: memory leak declaring closure in included file

From: Date: Mon, 08 Oct 2018 02:41:00 +0000
Subject: Bug #76982 [NEW]: memory leak declaring closure in included file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217462@lists.php.net to get a copy of this message
From:             ryan dot brothers at gmail dot com
Operating system: Linux
PHP version:      7.2.10
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:memory leak declaring closure in included file

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 bug report at https://bugs.php.net/bug.php?id=76982&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76982&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76982&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76982&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76982&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76982&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76982&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76982&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76982&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76982&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76982&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76982&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76982&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76982&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76982&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76982&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76982&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76982&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76982&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76982&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76982&r=mysqlcfg



Thread (10 messages)

« previous php.bugs (#217462) next »