From: technik at perlentaucher dot de Operating system: Linux PHP version: 5CVS-2004-05-17 (dev) PHP Bug Type: MSSQL related Bug description: Huge Memory Leak mysql_result()
Description: ------------ Hi all, mysql_result seems to leak memory as I Commented in Bug #27758. I thought it's worth a new Bugreport. I tried to find out more about it, so i wrote a Script that reads in Data from my DB and calculates Memory usage in a loop. The Table looks like that : 28000 identical Records ID : int11, auto_increment DATA : varchar(20) = 'ABCDEFGHIJKLMNOPQRTS' The Script reads all Records 300 Times before calculating memory usage. The Result looks like that : (mem in kb) Index Used Free Dif Start 176512 1326208 0 loop 1 176704 1326016 192 loop 2 176776 1325944 72 loop 3 176816 1325904 40 loop 4 176876 1325844 60 loop 5 177028 1325692 152 loop 6 177164 1325556 136 loop 7 177316 1325404 152 loop 8 177492 1325228 176 loop 9 177716 1325004 224 Absolute dif 1204 So usage of Memory is not same in every Loop !! But at the end I miss about 1.2M of my Memory. I also could not free this memory by killing httpd (killing mysqld also didn't help) I'm using gentoo, kernel is 2.4.20-gentoo-r7. Apache : 2.0.48 PHP5 : php5-200405131230 (cvs snap) Greetings, Adam Cwientzek Reproduce code: --------------- for ( $x=0; $x<300; $x++ ) { $db = mysql_connect("localhost", "root", "test"); mysql_select_db("test"); $sql = "select data from test"; $result = mysql_query($sql); // causes MEM-Leak !!!! mysql_free_result($result); mysql_close($db); } -- Edit bug report at http://bugs.php.net/?id=28424&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28424&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28424&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28424&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28424&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28424&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28424&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28424&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28424&r=support Expected behavior: http://bugs.php.net/fix.php?id=28424&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28424&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28424&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28424&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28424&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28424&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28424&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28424&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28424&r=float