Bug #80108 [Com]: APACHE+PHP not releasing memory in certain conditions on Win10
| From: | gilperon at gmail dot com | Date: | Thu, 17 Sep 2020 00:19:51 +0000 |
| Subject: | Bug #80108 [Com]: APACHE+PHP not releasing memory in certain conditions on Win10 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229033@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80108&edit=1
ID: 80108
Comment by: gilperon at gmail dot com
Reported by: gilperon at gmail dot com
Summary: APACHE+PHP not releasing memory in certain
conditions on Win10
Status: Re-Opened
Type: Bug
Package: *General Issues
Operating System: *
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
@nikic@php.net It also would be nice if at least Zend was smart enough to clear the cache everytime
a request is terminated/finished. Anyway I can force that?
Previous Comments:
------------------------------------------------------------------------
[2020-09-16 23:59:01] gilperon at gmail dot com
@nikic I tried what you said and it WORKED PERFECTLY!!! Literally perfectly. Right after executing
"gc_mem_caches" the RAM usage drops to the normal 5-6MB!
Pretty awesome! So I think I will have to throw
gc_mem_caches() all over my codes so it
does not trash the RAM! Maybe you know some way I can tell PHP to better optimize the RAM usage?
Something like: "hey PHP, if your Zend cache is over 500MB, please clear it." ?
------------------------------------------------------------------------
[2020-09-16 20:20:44] nikic@php.net
Try gc_mem_caches().
------------------------------------------------------------------------
[2020-09-16 20:18:35] gilperon at gmail dot com
Someone told me at SO to use:
gc_enable();
gc_collect_cycles();
However, even after using it, no memory is released. So how do I force Zend to release the
cache/memory?
------------------------------------------------------------------------
[2020-09-16 13:44:46] gilperon at gmail dot com
Wow, by the votes, some other people reported the same issue! Great, hope some responsible
non-sarcastic voluntary of PHP project can fix this. As I said, I know how memory management/leak
work, but I have 0 idea how PHP source code was implemented. It would take me months to study PHP
code only to fix this bug, so yeah, better hope that some good responsible person, that already
knows inner workings of PHP, decide to fix this, or at least take a close look instead of just
saying "this is expected behaviour, deal with it".
@cmb@php.net this is not expected, mainly if you have a server that gets thousands of requests like
this. It will trash the RAM in seconds.
------------------------------------------------------------------------
[2020-09-16 09:37:15] cmb@php.net
This is expected behavior. On request shutdown, the Zend memory
manager does not free all allocated chunks, but rather retains
some[1] to avoid the need to reallocate them possibly for the next
request.
That does not imply, that there are no real memory leaks in PHP,
but the given test script does not show any.
[1] <https://github.com/php/php-src/blob/php-7.4.10/Zend/zend_alloc.c#L2273>
------------------------------------------------------------------------
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=80108
--
Edit this bug report at https://bugs.php.net/bug.php?id=80108&edit=1