Bug #77773 [Com]: Unbuffered queries leak memory - MySQLi / mysqlnd

From: Date: Fri, 22 Mar 2019 20:30:06 +0000
Subject: Bug #77773 [Com]: Unbuffered queries leak memory - MySQLi / mysqlnd
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220134@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77773&edit=1 ID: 77773 Comment by: alex at alex-at dot net Reported by: alex at alex-at dot net Summary: Unbuffered queries leak memory - MySQLi / mysqlnd Status: Closed Type: Bug Package: MySQLi related Operating System: CentOS 7 PHP Version: 7.3.3 Block user comment: N Private report: N New Comment: Indeed, with the patch from GIT commit it's fine. Thanks! Previous Comments: ------------------------------------------------------------------------ [2019-03-22 12:15:56] nikic@php.net Related To: Bug #77713 ------------------------------------------------------------------------ [2019-03-22 12:07:24] nikic@php.net Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=30ddfd49edbd8066cc0a18a557e3de30c2397d12 Log: Fixed bug #77773 ------------------------------------------------------------------------ [2019-03-20 15:58:19] alex at alex-at dot net Description: ------------ This is actually is a followup of #77308, because following up already closed bug is meaningless. Still present in 7.3.3 Some details of test run: --- 1. Versions (tried both ZTS and NTS, same results) #/opt/php71/bin/php -v PHP 7.1.27 (cli) (built: Mar 18 2019 13:00:22) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies # /opt/php72/bin/php -v PHP 7.2.16 (cli) (built: Mar 18 2019 13:03:57) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies # /opt/php73/bin/php -v PHP 7.3.3 (cli) (built: Mar 18 2019 13:07:58) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies --- 2. Top data for ~10 sec of script run 7.1: 112241 root 20 0 307892 13932 8396 R 100.0 0.2 0:11.82 /opt/php71/bin/php ./test.php 7.2: 111796 root 20 0 310480 14228 8460 R 99.7 0.2 0:10.41 /opt/php72/bin/php ./test.php 7.3: 110517 root 20 0 1148804 848480 8716 R 99.7 10.4 0:10.37 /opt/php73/bin/php ./test.php You can easily see RES size growing from stable 14M on PHP 7.1/7.2 to 840M+ on PHP 7.3. The script fails with out of memory error eventually (Allowed memory size of 1073741824 bytes exhausted (tried to allocate 16384 bytes) in /config/scripts/test.php on line 10) --- 3. Script excerpt (it's ultimately simple, but the query returns 11+ million rows) is provided as 'Test script' Test script: --------------- #!/opt/php73/bin/php <?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('memory_limit', '1G'); $db = new MySQLi('<server>', '<login>', '<password>', 'radius'); $res = $db->query('SELECT AcctSessionId AS sid, AcctUniqueId AS uid FROM radacct ORDER BY AcctSessionId, AcctUniqueId', MYSQLI_USE_RESULT); while (is_array($row = $res->fetch_assoc())); $res->free(); Expected result: ---------------- Memory does not leak Actual result: -------------- Memory leaks ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77773&edit=1

« previous php.bugs (#220134) next »