Bug #77599 [NEW]: Unbuffered queries; native prepared statements memory leak
| From: | dylan at php dot waywardrambler dot com | Date: | Mon, 11 Feb 2019 03:23:54 +0000 |
| Subject: | Bug #77599 [NEW]: Unbuffered queries; native prepared statements memory leak | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-219485@lists.php.net to get a copy of this message | ||
From: dylan at php dot waywardrambler dot com
Operating system: MacOS 10.14.3
PHP version: 7.3.2
Package: PDO MySQL
Bug Type: Bug
Bug description:Unbuffered queries; native prepared statements memory leak
Description:
------------
Memory leak when running unbuffered queries in PDO with
ATTR_EMULATE_PREPARES set to false.
Test script:
---------------
<?php
ini_set('memory_limit', '16M');
$pdo = new PDO('mysql:host=*;dbname=*', '*', '*');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$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:
----------------
consistent memory usage, eg:
0 2097152
10000 2097152
20000 2097152
30000 2097152
40000 2097152
Actual result:
--------------
0 2097152
10000 4194304
20000 8388608
30000 12582912
40000 14680064
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to
allocate 16384 bytes) in /php on line 10
--
Edit bug report at https://bugs.php.net/bug.php?id=77599&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77599&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77599&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77599&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77599&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77599&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77599&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77599&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77599&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77599&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77599&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77599&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77599&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77599&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77599&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77599&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77599&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77599&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77599&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77599&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77599&r=mysqlcfg