Bug #51796 [Opn->Fbk]: Memory leak when executing SQL "EXEC" statements

From: Date: Wed, 12 May 2010 16:43:38 +0000
Subject: Bug #51796 [Opn->Fbk]: Memory leak when executing SQL "EXEC" statements
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150407@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51796&edit=1

 ID:               51796
 Updated by:       sixd@php.net
 Reported by:      J dot Antonio at jaruz dot com
 Summary:          Memory leak when executing SQL "EXEC" statements
-Status:           Open
+Status:           Feedback
 Type:             Bug
 Package:          PDO related
 Operating System: Ubuntu 10.04 LTS
 PHP Version:      5.3.2

 New Comment:

Try the patches and see if your bug is a duplicate.


Previous Comments:
------------------------------------------------------------------------
[2010-05-12 18:41:32] sixd@php.net

For reference, there are some pdo_dblib patches mentioned in 
http://bugs.php.net/50755

------------------------------------------------------------------------
[2010-05-11 17:50:44] J dot Antonio at jaruz dot com

I forgot to mention this is using PDO_DBLIB.

------------------------------------------------------------------------
[2010-05-11 17:48:35] J dot Antonio at jaruz dot com

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 this bug report at http://bugs.php.net/bug.php?id=51796&edit=1


Thread (5 messages)

« previous php.bugs (#150407) next »