Bug #76053 [NEW]: Memory leaks when executing prepared statements

From: Date: Mon, 05 Mar 2018 16:50:25 +0000
Subject: Bug #76053 [NEW]: Memory leaks when executing prepared statements
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214209@lists.php.net to get a copy of this message
From: hello at spaceemotion dot net Operating system: Ubuntu PHP version: 7.2Git-2018-03-05 (snap) Package: PDO MySQL Bug Type: Bug Bug description:Memory leaks when executing prepared statements Description: ------------ I've just come across an out of memory issue in a larger CLI-command that does lots calculations across multiple tables. The command ran fine on 7.1.x but errors on 7.2.2. I've nailed it down to the PDOStatement class (using Blackfire.io) sometimes creating 26 kb garbage _per call_. The attached test script should not create any garbage whatsoever, and even the gc_collect_cycles call does not reduce the memory footprint. Everything works when running it under 7.1. Opcache is disabled (for CLI). Test script: --------------- <?php $dsn = 'mysql:dbname=homestead;host=127.0.0.1'; $user = 'homestead'; $password = 'secret'; $pdo = new PDO($dsn, $user, $password); for($i = 0; $i < 1000000; $i++) { echo memory_get_usage() . "\n"; $statement = $pdo->prepare('SELECT * FROM demo'); $statement->execute(); gc_collect_cycles(); // does not help as well } Expected result: ---------------- 362504 107678504 107678504 107678504 107678504 107678504 107678504 107678504 Actual result: -------------- 574888 100246184 100246312 100246440 100246568 100246696 100246824 100246952 -- Edit bug report at https://bugs.php.net/bug.php?id=76053&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76053&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76053&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76053&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76053&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76053&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76053&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76053&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76053&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76053&r=support Expected behavior: https://bugs.php.net/fix.php?id=76053&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76053&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76053&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76053&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76053&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76053&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76053&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76053&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76053&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76053&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76053&r=mysqlcfg

« previous php.bugs (#214209) next »