Bug #78525 [NEW]: Memory leak in pdo when reusing native prepared statements
| From: | victoria at sharksmedia dot dk | Date: | Wed, 11 Sep 2019 10:36:28 +0000 |
| Subject: | Bug #78525 [NEW]: Memory leak in pdo when reusing native prepared statements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222692@lists.php.net to get a copy of this message | ||
From: victoria at sharksmedia dot dk
Operating system: CentOS 7.6.1810
PHP version: 7.3.9
Package: PDO MySQL
Bug Type: Bug
Bug description:Memory leak in pdo when reusing native prepared statements
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 bug report at https://bugs.php.net/bug.php?id=78525&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78525&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78525&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78525&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78525&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78525&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78525&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78525&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78525&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78525&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78525&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78525&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78525&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78525&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78525&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78525&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78525&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78525&r=mysqlcfg