From: Operating system: Ubuntu 10.04 LTS PHP version: 5.3.2 Package: PDO related Bug Type: Bug Bug description:Memory leak when executing SQL "EXEC" statements
Description: ------------ On Linux, using PHP 5.3.2-1ubuntu4 with Suhosin-Patch (cli) and FreeTDS 0.82-6build1 (it's a vanilla lucid install, fully up to date): When executing stored procedures using the "EXEC" SQL statement, both PDOStatement->execute as well as PDO::query seem to have a memory leak. We found this while executing a stored procedure within a loop: memory usage just kept increasing till the memory limit was reached. Unsetting/nullyfing variables does not help. The leak is not present (memory usage stays perfectly constant) when using a "SELECT" SQL statement (which returns the exact same results as the stored procedure). I have a feeling PDO is maybe only clearing the memory when it deals with a "SELECT" statement, and it misses the fact that data can also come back through "EXEC" statements? This bug might be slightly related to bug 50755. Test script: --------------- // $polyItemArray is populated with a list of 300 IDs (integers). // We loop through the array, and execute a stored procedure during each iteration: foreach( $polyItemArray as $polyItemKey => $polyItem) { echo date('H:i:s') . ' | Processing: ' . $polyItem['sgp_id']; $dbh->query('EXEC proc_map_get_sgp_polygons ' . $polyItem['sgp_id'], PDO::FETCH_ASSOC); /* // Alternate way of calling the procedure using PDOStatement; same leak is present: $stmt = $dbh->prepare($sql); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->execute( array($polyItem['sgp_id']) ); $stmt->closeCursor(); unset($stmt); */ unset($polyItemKey); unset($polyItem); echo ' memory usage: ' . memory_get_usage(). ' bytes'. PHP_EOL; } // When running the script, memory usage just keeps increasing. Expected result: ---------------- I would expect the memory usage of the script to stay constant. Actual result: -------------- Memory usage just keeps increasing. -- Edit bug report at http://bugs.php.net/bug.php?id=51796&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51796&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51796&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51796&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51796&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51796&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51796&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51796&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51796&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51796&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51796&r=support Expected behavior: http://bugs.php.net/fix.php?id=51796&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51796&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51796&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51796&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51796&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51796&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51796&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51796&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51796&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51796&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51796&r=mysqlcfg