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

From: Date: Thu, 17 Sep 2020 23:20:33 +0000
Subject: Bug #80117 [Com]: Apache and PHP leaking memory and also does not releasing it
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229064@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80117&edit=1 ID: 80117 Comment by: gilperon at gmail dot com Reported by: gilperon at gmail dot com Summary: Apache and PHP leaking memory and also does not releasing it Status: Not a bug Type: Bug Package: *General Issues Operating System: WINDOWS 10 AND CENTOS 8 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: First of all, it's not a matter if apache will crash or not. It's about gc_mem_caches() and gc_collect_cycles() not working as they should. Because in some circunstances those 2 functions look to work fine (as the explode example I gave you in another bug report - on that thread the function gc_mem_caches() worked perfectly, completely reseting memory usage to initial values when apache was restarted). HOWEVER now, with the new code I provided you, those 2 functions are not working as expected. So I think the main issue here is not wheter apache will crash or not, but WHY those 2 functions are not doing what they are supposed to? With the code I provided you on this thread I am sure gc_collect_cycles() should not help anything, BUT gc_mem_caches() should help clearing the entire cache. Previous Comments: ------------------------------------------------------------------------ [2020-09-17 18:19:41] danack@php.net > So, if you have a VPS with 2GB of RAM (which is already PRETTY LOW) and you run my sample code, > you will probably crash your Apache with less than 15 requests. "probably" Or maybe, the Apache memory manager will kick in and free the memory. As I said, if you are seeing it crash that would be one thing. But you're saying: > HOWEVER, if I execute that same exactly script over, and over, and over... in less than 15 > requests I will end up consuming my entire VPS RAM memory (2GB) with TRASH/CACHE. Which reads to me as if you think it will crash....but it probably won't. ------------------------------------------------------------------------ [2020-09-17 18:07:48] gilperon at gmail dot com My friend, I will copy the phrase where I told you my Apache is crashing on RAM: "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, if you have a VPS with 2GB of RAM (which is already PRETTY LOW) and you run my sample code, you will probably crash your Apache with less than 15 requests. I also have to clear one thing you said "are you having a problem with a script using all the memory". NO! I am not having problems with my script using all my RAM. No! My script runs fine, it starts fine, finishes fine with lots of RAM to spare. HOWEVER, if I execute that same exactly script over, and over, and over... in less than 15 requests I will end up consuming my entire VPS RAM memory (2GB) with TRASH/CACHE. I am not complaning about my script using lots of memory, NO! I am complaining about PHP leaving lots of trash behind AFTER executing my code, so this trash adds up in a short time and crashes apache. ------------------------------------------------------------------------ [2020-09-17 17:29:30] danack@php.net > danack@php.net did you read everyhing I told you? Yes. > and error_log file will say that apache is "Out of > memory". I'm being blind. I can't see anything about a log file. Where is this in your bug report? Okay, this is a wild guess; are you having a problem with a script using all the memory, and are trying to make a reproduce case? ------------------------------------------------------------------------ [2020-09-17 17:23:03] gilperon at gmail dot com danack@php.net did you read everyhing I told you? As you execute that same script a few dozen times, it will end up consuming all system RAM memory and error_log file will say that apache is "Out of memory". You said "Until you actually see some result that causes an actual problem". So, isnt this a problem? Apache is yelling at me, saying I have no more memory after my server receives only a few requests (not at the same time, the requests are mostly one after another). If you think this is not a problem, I have no idea what you consider being a problem. ------------------------------------------------------------------------ [2020-09-17 17:12:38] danack@php.net Hi, It turns out that computers are complicated. Exactly what is happening on your system isn't obvious, but trying to figure out of something has a memory leak or not, just by looking at Windows Task Manager isn't the way to go about it. It could just be that "that's how Apache delays releasing memory", or "that's just how windows task manager is". If there was a real memory leak, you'd be able to make apache crash (or at the very least slow down drastically). But seeing high memory usage numbers in Task Manager doesn't actually indicate a fault. Until you actually see some result that causes an actual problem (like a reproducible crash, or unable to serve requests), please refrain from opening bug tickets about system metrics you are seeing, as they aren't a useful thing for people to be looking at. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=80117 -- Edit this bug report at https://bugs.php.net/bug.php?id=80117&edit=1

« previous php.bugs (#229064) next »