Bug #81536 [NEW]: Resident Memory not returned after use

From: Date: Mon, 18 Oct 2021 07:03:45 +0000
Subject: Bug #81536 [NEW]: Resident Memory not returned after use
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237250@lists.php.net to get a copy of this message
From:             dev at alepe dot com
Operating system: Linux
PHP version:      7.3.31
Package:          Performance problem
Bug Type:         Bug
Bug description:Resident Memory not returned after use

Description:
------------
PHP7-PHP8 is not releasing "Resident Memory" back to the OS after use
(specially Wordpress sites). PHP5 works as expected, example:

PHP5  : 10MB ---> 95MB ---> 10MB
PHP7+ : 10MB ---> 95MB ---> 95MB

Versions Used:
* PHP7 versions 7.2, 7.3, 7.4 and 8.0 (running as FastCGI in lighttpd)
* Linux OS: Alpine 3.10, Alpine 3.14 and Ubuntu 20.04
* Wordpress: 5.7, 5.8

I have tested it without Wordpress (using the provided test script) but
the result is not conclusive (across versions), however when using
Wordpress, it always happen.

We noticed after several sites (about 500 sites) were updated from PHP 5
to PHP 7 (running in LXD containers), as the memory consumption
increased about 3 to 4 times, making the server performance to go down
drastically (server started to swap more often). Even when the sites are
not accessed for a long time, the memory is not released.

Settings: Almost all sites are running the default settings (opcache is
OFF)

Memory checking tools: htop, top and lxc info

Modules used:

ctype
curl
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
readline
Reflection
session
SPL
standard
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib


Test script:
---------------
<?php
// NOTE: this code SOMETIMES produces the problem described above, 
//       and sometimes it won't.
$m = "";
for($i = 0; $i < 110000; $i++) {
    $m .=
"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
}
sleep(3);
echo "DONE";
?>



-- 
Edit bug report at https://bugs.php.net/bug.php?id=81536&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81536&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81536&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81536&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81536&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81536&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81536&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81536&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81536&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81536&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81536&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81536&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81536&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81536&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81536&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81536&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81536&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81536&r=mysqlcfg


Thread (7 messages)

« previous php.bugs (#237250) next »