Bug #77308 [Com]: Unbuffered queries memory leak

From: Date: Fri, 28 Dec 2018 21:06:31 +0000
Subject: Bug #77308 [Com]: Unbuffered queries memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218667@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77308&edit=1

 ID:                 77308
 Comment by:         cweiske@php.net
 Reported by:        sjon at hortensius dot net
 Summary:            Unbuffered queries memory leak
 Status:             Open
 Type:               Bug
 Package:            MySQL related
 Operating System:   archlinux
 PHP Version:        7.3.0
 Block user comment: N
 Private report:     N

 New Comment:

This breaks Roundcube webmail, see https://bugs.archlinux.org/task/61139.
Happens here with 7.3.0-2 (Debian 9)


Previous Comments:
------------------------------------------------------------------------
[2018-12-17 09:16:01] sjon at hortensius dot net

Description:
------------
commit f1f1f6 broke unbuffered queries in mysqlnd; there is a memory leak causing php to run out of
memory

Test script:
---------------
<?php
ini_set('memory_limit', '8M');

$pdo = new PDO('mysql:host=*;dbname=*', '*', '*');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);

$result = $pdo->query("SELECT * FROM large_table");

foreach ($result as $i => $row)
	if ($i % 10000 === 0)
		printf("%10s %10s\n", $i, memory_get_usage());


Expected result:
----------------
reasonable constant memory usage, eg:

         0     427648
     10000     427936
     20000     427968
     30000     427968
     40000     427936


Actual result:
--------------
         0     427296
     10000    2000288
     20000    3622336
     30000    5260736
     40000    6915488

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16384 bytes) in /php
on line 10



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77308&edit=1


Thread (13 messages)

« previous php.bugs (#218667) next »