From:
Operating system: Windows Vista
PHP version: 5.3.10
Package: MySQL related
Bug Type: Bug
Bug description:MySQL memory leak
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 bug report at https://bugs.php.net/bug.php?id=61060&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61060&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61060&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61060&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61060&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61060&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61060&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61060&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61060&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61060&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61060&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61060&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61060&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61060&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61060&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61060&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61060&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61060&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61060&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61060&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61060&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61060&r=mysqlcfg