Bug #80108 [NEW]: Major bug on APACHE+PHP not releasing memory in certain conditions on Win10
| From: | gilperon at gmail dot com | Date: | Tue, 15 Sep 2020 22:33:09 +0000 |
| Subject: | Bug #80108 [NEW]: Major bug on APACHE+PHP not releasing memory in certain conditions on Win10 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-229019@lists.php.net to get a copy of this message | ||
From: gilperon at gmail dot com
Operating system: WINDOWS 10 AND CENTOS 8
PHP version: 7.4.10
Package: *General Issues
Bug Type: Bug
Bug description:Major bug on APACHE+PHP not releasing memory in certain conditions on Win10
Description:
------------
I am running latest APACHE (2.5.x) + PHP (7.x) on my Win10 computer
which has 8GB of RAM. All configurations are default.
When I start my Apache and check Windows Task Manager it shows the two
Apache processes are using about 5 to 6 MB of RAM. Great.
Now I saved the code below on a test.php file and execute it using my
browser like this http://localhost/test.php
The contents of that file is pretty simple, just this:
<?php
set_time_limit(0);
ini_set("memory_limit","-1");
$temp = str_repeat("ffkl2kfj\nflkdsjf \rflksdjfldskjLJFDSL
djsk|fhgjk{}fkgkjfdk",10000000);
explode("|",$temp);
echo "ended";
?>
After executing the code above and waiting till it shows ended, one of
my Apache processes shows 400MB of RAM being consumed (the other Apache
process is with 5-6MB of RAM). If I execute that code again, Apache will
consume 700MB. Then again, it will show 850MB and so on. That's the bug
itself. I know how memory leak works, how memory management works,
variable lifecycle, stacks... So I came up with the minimum code to show
you this bug.
NOW what is impressive, if that if after you call a few times the file
test.php on your browser, if you create another file named test2.php
with the contents being only <?php echo "x"; ?>, and if you execute that
same file using your browser, you will see Apache memory usage drops to
exactly HALF! Now execute it again, Apache`s consumed RAM will drop
again exactly by 50%... and so on. Keep doing this until it reaches
5-6MB and it will stop dropping.
What is going on? This is a big problem to me and the only "escape" is
creating scheduled task to restart Apache every 12 hours. I need to fix
this cause in this computer I run a small webservice to a few friends
and every once in a while Apache reaches almost 100% of memory usage and
I need to restart it manually, even this webservice receiving no more
than 10 or 20 requests a day. For some reason, Apache is not completely
cleaning its memory after each request.
I know I should be using a linux distro (like Centos 8.x that I run on a
VPS) if I want to run a realiable LAMP stack, but this bug is still
pretty weird.
I am pretty sure PHP is doing something weird on the background which is
not cleaning cache or any memory assigned location.
Test script:
---------------
<?php
set_time_limit(0);
ini_set("memory_limit","-1");
$temp = str_repeat("ffkl2kfj\nflkdsjf \rflksdjfldskjLJFDSL
djsk|fhgjk{}fkgkjfdk",10000000);
explode("|",$temp);
echo "ended";
?>
Expected result:
----------------
Memory should be released as soon the request was finished.
Actual result:
--------------
Memory is not being cleaned.
--
Edit bug report at https://bugs.php.net/bug.php?id=80108&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80108&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80108&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80108&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80108&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80108&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80108&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80108&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80108&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80108&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80108&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80108&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80108&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80108&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80108&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80108&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80108&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80108&r=mysqlcfg