php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54329 MSSql extension memory leak
Submitted: 2011-03-21 03:24 UTC Modified: 2011-07-03 15:01 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: dotslashpok at gmail dot com Assigned: felipe (profile)
Status: Closed Package: MSSQL related
PHP Version: 5.3SVN-2011-03-21 (SVN) OS: Red Hat,Windows 7
Private report: No CVE-ID: None
 [2011-03-21 03:24 UTC] dotslashpok at gmail dot com
Description:
------------
Fetching data through dblib causes php memory usage to go up after each query. 
This occurs even after unsetting the retrieved data.

This is because free_rows is not freeing the correct data.

Test script:
---------------
<?php
$db = new PDO('...','...','...');
$stmt = $db->prepare('SELECT TOP 100 * FROM Users');
echo "Start Memory : ".memory_get_peak_usage()."\n";

for ($i = 0; $i < 10; $i++) {

	$stmt->execute();
	$data = $stmt->fetchAll();

	unset($data);
	gc_collect_cycles();	
	echo $i." : ".memory_get_peak_usage()."\n";
}
echo "End Memory : ".memory_get_peak_usage()."\n";

Expected result:
----------------
Memory usage should be similar after each execution

Start Memory : 630824
0 : 1257944
1 : 1258024
2 : 1258920
3 : 1258920
4 : 1258984
5 : 1259048
6 : 1259096
7 : 1259224
8 : 1259288
9 : 1259296
End Memory : 1259296


Actual result:
--------------
Memory usage increases significantly after each execution

Start Memory : 630824
0 : 1257944
1 : 1321216
2 : 1384528
3 : 1447688
4 : 1510920
5 : 1574192
6 : 1637464
7 : 1700736
8 : 1763960
9 : 1827208
End Memory : 1827208


Patches

dblibmemoryleakfix (last revision 2011-03-21 02:25 UTC by dotslashpok at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-03 15:01 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=312860
Log: - Fixed bug #54329 (MSSql extension memory leak)
  patch by: dotslashpok at gmail dot com
 [2011-07-03 15:01 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-07-03 15:01 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for the patch!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 00:01:29 2024 UTC