php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77173 include and new anonymous class bug
Submitted: 2018-11-19 05:46 UTC Modified: 2021-05-22 09:15 UTC
Votes:4
Avg. Score:3.2 ± 1.1
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: admin at yurunsoft dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.1.24 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admin at yurunsoft dot com
New email:
PHP Version: OS:

 

 [2018-11-19 05:46 UTC] admin at yurunsoft dot com
Description:
------------
when I include a file, the file new a anonymous class and return, more and more memory usage

Test script:
---------------
<?php
class A
{

}

file_put_contents(__DIR__ . '/tmp.php', '<?php return new class extends A{};');

while(true)
{
	$a = include __DIR__ . '/tmp.php';
	usleep(1000);
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-19 07:52 UTC] spam2 at rhsoft dot net
what else do you expect when you include a file in and endless loop?
 [2018-11-19 08:18 UTC] admin at yurunsoft dot com
you can try this code, it's ok!

<?php
class A
{

}

while(true)
{
    $a = new class extends A{};
    usleep(1000);
}
 [2018-11-19 09:54 UTC] spam2 at rhsoft dot net
which proves that it is a bad idea include code in a loop
 [2018-11-19 11:37 UTC] cmb@php.net
I cannot reproduce memory issues with PHP 7.1.24.  Is OPcache or
some other bytecode cache involved?
 [2018-11-20 00:47 UTC] admin at yurunsoft dot com
my extensions:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
inotify
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
swoole
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zlib


I use htop to check and find that php's RES is getting higher and higher.
 [2018-11-21 09:49 UTC] wi1dcard dot cn at gmail dot com
Simpler test case:


while(true)
{
    $func = eval('return function () {};');
    var_dump($func);
    unset($func);
    
    usleep(1000);
}
 [2021-05-22 09:15 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2021-05-22 09:15 UTC] krakjoe@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 05:01:30 2024 UTC