Bug #61060 [Com]: MySQL memory leak
| From: | jim at bladehq dot com | Date: | Tue, 10 Apr 2012 16:59:23 +0000 |
| Subject: | Bug #61060 [Com]: MySQL memory leak | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-169412@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61060&edit=1
ID: 61060
Comment by: jim at bladehq dot com
Reported by: trusty_jim at hotmail dot com
Summary: MySQL memory leak
Status: Open
Type: Bug
Package: MySQL related
Operating System: Windows Vista
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
I have experienced this issue too. It appears to only leak memory when the query is SELECT *. This
has caused our application to run out of memory when iterating over large result sets.
Previous Comments:
------------------------------------------------------------------------
[2012-02-12 03:50:28] trusty_jim at hotmail dot com
Description:
------------
Fetching data through mysql_fetch_assoc() causes php memory usage to go up after
each query.
This occurs even after unsetting the retrieved data.
Test script:
---------------
<?php
$db = mysql_connect(DB_DOMAIN, DB_USERNAME, DB_PASS, true);
echo "Start Memory : ".memory_get_usage()."\n";
$result = mysql_query('SELECT * FROM addr', $db);
for ($i = 0; $i < 10; $i++) {
$row = mysql_fetch_assoc($result);
if ($row === false) break;
unset($row);
gc_collect_cycles();
echo " ".memory_get_usage()."\n";
}
mysql_free_result($result);
echo "End Memory : ".memory_get_usage()."\n";
?>
Expected result:
----------------
Memory usage should be similar after each execution
Start Memory : 31108008
65407576
65407576
65407576
65407576
65407576
65407576
65407576
65407576
65407576
65407576
End Memory : 31108160
Actual result:
--------------
Memory usage increases significantly after each execution
Start Memory : 31108008
65407576
65408120
65408664
65409208
65409752
65410296
65410840
65411384
65411944
65412488
End Memory : 31108160
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61060&edit=1