[php-src] Issue #13775: Unknown memory leak in PHP 8.2 FPM

From: Date: Thu, 21 Mar 2024 14:03:17 +0000
Subject: [php-src] Issue #13775: Unknown memory leak in PHP 8.2 FPM
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246629@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13775 Author: jreklund ### Description This is an follow up on the issue hi-jacking I did earlier (sorry!). I haven't been able to replicate the issue in development or on our test servers during this time. So I tried a memory profiler on the production server, without any luck. Now I need some new advice from some experts! https://github.com/php/php-src/issues/8646#issuecomment-1695295584 After running our application for about an hour we start to see an unhealthy amount of RAM usage. Fast forward a couple of hours and our sever will run out of RAM and start writing to disk instead. PHP versions tested: 8.2.17, 8.2.14, 8.2.12, 8.2.9, 8.2.8, 8.2.7, 8.2.5, 8.2.4 Configuration: https://github.com/php/php-src/issues/8646#issuecomment-1695295584 ``` sudo add-apt-repository ppa:ondrej/php sudo apt update -y sudo apt install php8.1-common php8.1-fpm php8.1-gd php8.1-mysql php8.1-mbstring php8.1-intl php8.1-xml php8.1-redis php8.1-curl ``` --- 12 days with PHP 8.1.27 and we utilize 1.3 GB of RAM. Same utilization can be seen using PHP 5.6 - 8.1. ![php-memory-2024-03-20-81](https://github.com/php/php-src/assets/3641536/0529cba8-6024-4918-b5a3-f927eb15eabc) --- Around 3 hours with PHP 8.2.17 and we utilize 4.5 GB of RAM. This will build up to use all available memory. ![php-memory-2024-03-20-82](https://github.com/php/php-src/assets/3641536/d6516565-99b7-40a3-9533-5939b2fae652) --- I tried to use valgrind massif tool to locate the issue, but it's stable for 7 hours. I have made two runs, using these settings, they give us the same behavior. ``sudo valgrind --tool=massif /usr/sbin/php-fpm8.2`` ``sudo valgrind --tool=massif /usr/sbin/php-fpm8.2 --nodaemonize --fpm-config /etc/php/8.2/fpm/php-fpm.conf`` ![php-memory-2024-03-20-massif](https://github.com/php/php-src/assets/3641536/b2a05ee6-8271-4bfd-b5bb-669aabd8f0c4) ``` MB 4.480^ # | # :::::::::::@:::::::::::::::::@:@: | #::::: :: : ::: @:::: ::: :::: :::@:@:: | #: :: :: : ::: @:::: ::: :::: :::@:@:: | #: :: :: : ::: @:::: ::: :::: :::@:@:: | @#: :: :: : ::: @:::: ::: :::: :::@:@:: | @#: :: :: : ::: @:::: ::: :::: :::@:@:: | @#: :: :: : ::: @:::: ::: :::: :::@:@:: | @#: :: :: : ::: @:::: ::: :::: :::@:@:: | @@#: :: :: : ::: @:::: ::: :::: :::@:@:: | @@#: :: :: : ::: @:::: ::: :::: :::@:@:: | @@#: :: :: : ::: @:::: ::: :::: :::@:@::: | @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | ::::@@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | :::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | ::::::::::::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | :@:: :::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | ::::@:: :::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | : ::@:: :::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: | ::: ::@:: :::::: @@@#: :: :: : ::: @:::: ::: :::: :::@:@::: 0 +----------------------------------------------------------------------->Mi 0 121.6 Number of snapshots: 52 Detailed snapshots: [6, 16, 17, 18, 19 (peak), 30, 45, 47] ``` --- @nielsdos You helped me out before and stated there was another way of using a memory profiler. I didn't see any memory leak using Valgrid thought. But these servers fail 100% of time not using Valgrid. > Did you observe memory leaking behaviour of this run? If yes, that means the problem is somehow > not originating from a persistent allocation, and we can give instructions on how to include request > memory inside the graphs. - Is it still worth tracking request? If not, I will start testing our application with PHP 8.2.0 to see if it's compatible before going the git-bisect route. ### PHP Version 8.2.17 ### Operating System Ubuntu 22.04.4

« previous php.bugs (#246629) next »