Bug #80117 [NEW]: Apache and PHP leaking memory and also does not releasing it

From: Date: Thu, 17 Sep 2020 16:49:48 +0000
Subject: Bug #80117 [NEW]: Apache and PHP leaking memory and also does not releasing it
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229053@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: Irrelevant Package: *General Issues Bug Type: Bug Bug description:Apache and PHP leaking memory and also does not releasing it Description: ------------ This case is similar to a previous one I reported in this bug tracker, but that other case was solved by simply using "gc_mem_caches". HOWEVER this new case DOES NOT work by using "gc_mem_caches". 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"); for ($i=0;$i<20000000;$i++) { $a[] = md5($i); } unset($a); gc_mem_caches(); ?> After executing the code above, one of Apache process RAM went up to close to 1GB and after a few seconds it went down to the original 5-6MB (same as when I started Apache). However if I execute that exactly same code again (without restarting/reloading Apache), after the end I will be left with Apache using 400MB. And that's not all! If I keep executing that same code again, and again, and again... Apache RAM usage increases every single time the script finishes its execution by about 180MB. So Apache is probably leaking memory somewhere and is never releasing it. I already tried "gc_enable(); gc_collect_cycles();" but it does not work (of course, I am not using references). Test script: --------------- <?php set_time_limit(0); ini_set("memory_limit","-1"); for ($i=0;$i<20000000;$i++) { $a[] = md5($i); } unset($a); gc_mem_caches(); ?> Expected result: ---------------- Memory should go back to 5-6MB. Actual result: -------------- Memory leak or increase memory usage. -- Edit bug report at https://bugs.php.net/bug.php?id=80117&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80117&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80117&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80117&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80117&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80117&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80117&r=support Expected behavior: https://bugs.php.net/fix.php?id=80117&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80117&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80117&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80117&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80117&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80117&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80117&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80117&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80117&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80117&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80117&r=mysqlcfg

« previous php.bugs (#229053) next »