Bug #81585 [Com]: cached_chunks are not counted to real_size on shutdown

From: Date: Tue, 08 Feb 2022 06:17:54 +0000
Subject: Bug #81585 [Com]: cached_chunks are not counted to real_size on shutdown
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239552@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81585&edit=1 ID: 81585 Comment by: Nayanamtech9 at gmail dot com Reported by: xtpd17 at gmail dot com Summary: cached_chunks are not counted to real_size on shutdown Status: Closed Type: Bug Package: Scripting Engine problem Operating System: * PHP Version: 7.4 Assigned To: cmb Block user comment: N Private report: N New Comment: Hi, i am aman i am here to give you information about the credit cards. <a href="https://soundcloud.com/aman-gupta-354684592">bank credit cards</a> Previous Comments: ------------------------------------------------------------------------ [2021-12-10 11:27:07] git@php.net Automatic comment on behalf of cmb69 Revision: https://github.com/php/php-src/commit/5675ebe649352ffa89754defd87019223b88b4e5 Log: Fix #81585: cached_chunks are not counted to real_size on shutdown ------------------------------------------------------------------------ [2021-12-09 14:37:47] cmb@php.net The following pull request has been associated: Patch Name: Fix #81585: cached_chunks are not counted to real_size on shutdown On GitHub: https://github.com/php/php-src/pull/7745 Patch: https://github.com/php/php-src/pull/7745.patch ------------------------------------------------------------------------ [2021-12-07 14:28:15] cmb@php.net The following pull request has been associated: Patch Name: Fix #81585: Reused cached_chunks are not counted to heap size On GitHub: https://github.com/php/php-src/pull/7732 Patch: https://github.com/php/php-src/pull/7732.patch ------------------------------------------------------------------------ [2021-12-07 14:21:58] cmb@php.net Setting ThreadsPerChild 1 actually yields only 1 worker thread; the other threads are ancilliary. Anyhow, the problem is that we don't count reused cached_chunks (i.e. those which are retained between requests) to the size of the heap, so the memory stats are wrong, and the memory_limit is not properly heeded. The latter causes the reported memory leak, because the script is trying to exploit that. This is not particularly related to Windows and Apache, but happens for all web environments, i.e. whenever a process or thread serves multiple consecutive requests (and chunks are cached). ------------------------------------------------------------------------ [2021-11-29 17:53:28] cmb@php.net First, the fact that not all request memory is freed on shutdown, is a deliberate design decisions[1]. The reasoning is that later reallocation of the memory from the OS is expensive. Second, the total amount of memory allocated (httpd_mb) can easily exceed PHP's memory_limit for a multi-threaded environment such as Apache mpm_winnt. If I set ThreadsPerChild 1 (note there is only one child for mpm_winnt), I still get four threads (might be a hard coded limit). Then the maximum amount of memory allocated is about four times the memory_limit, so this doesn't look like a bug. However, the reported values for memory_get_usage() are not what I would have expected; it seems that memory_get_usage(true) reports the per thread values, but memory_get_usage(false) return the process values. I'll have a closer look. [1] <https://github.com/php/php-src/blob/php-7.4.26/Zend/zend_alloc.c#L2264> ------------------------------------------------------------------------ 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=81585 -- Edit this bug report at https://bugs.php.net/bug.php?id=81585&edit=1

« previous php.bugs (#239552) next »