Bug #78525 [Opn->Ver]: Memory leak in pdo when reusing native prepared statements
| From: | nikic@php.net | Date: | Wed, 11 Sep 2019 10:45:53 +0000 |
| Subject: | Bug #78525 [Opn->Ver]: Memory leak in pdo when reusing native prepared statements | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222693@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78525&edit=1
ID: 78525
Updated by: nikic@php.net
Reported by: victoria at sharksmedia dot dk
Summary: Memory leak in pdo when reusing native prepared
statements
-Status: Open
+Status: Verified
Type: Bug
Package: PDO MySQL
Operating System: CentOS 7.6.1810
PHP Version: 7.3.9
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2019-09-11 10:36:28] victoria at sharksmedia dot dk
Description:
------------
If a native prepared statement is reused, it will leak memory on each reuse.
If the statement is prepared each time, there is no memory leak.
All versions of PHP 7.2 works, and all versions of PHP 7.3 leaks memory.
Versions:
Percona MySQL 5.7 & 8.0
PHP 7.3.x
Mysqlnd: mysqlnd 5.0.12-dev
The call to closeCursor() doesn't change anything.
Test script:
---------------
$pdo = new \PDO('mysql:host=<host>;dbname=<dbname>', 'user',
'password');
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
$stmt = $pdo->prepare('SELECT field FROM table LIMIT 100');
for($i=0;$i<250000;$i++)
{
$stmt->execute();
$stmt->fetchAll();
//$stmt->closeCursor();
if($i%1000 === 0) print memory_get_usage()."\r\n";
}
Expected result:
----------------
PHP 7.2.22:
446824
446856
446856
446856
446856
446856
446856
446856
446856
446856
446856
446856
446856
446856
446856
Actual result:
--------------
PHP 7.3.9:
479176
970728
1445864
1937384
2428904
2920424
3411944
3903464
4378600
4870120
5361640
5853160
6344680
6836200
7327720
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78525&edit=1