From: hkmaly at bigfoot dot com Operating system: Linux PHP version: 4.3.8 PHP Bug Type: Unknown/Other Function Bug description: php leaks memory when using references
Description: ------------ If I play with references, I found php doesn't properly free all memory in arrays with references ... for example don't free all memory in local variables of function. By repeating calling that function, leak can lead to consumation of all allowed memory. BTW, submited also as http://bugs.gentoo.org/show_bug.cgi?id=63559 Reproduce code: --------------- <?php function testLeak() { $a=array("jablka","hrusky","petr"=>"zeli"); foreach($a as $k=>$v) { $b[$k]=&$a; $b[$k]['names']=&$a; } return($b); } echo memory_get_usage()."\n"; for($i=0;$i<200000;$i++) { testLeak(); echo memory_get_usage()."\n"; } ?> Expected result: ---------------- Something as 20720 21816 22144 22144 22144 .... 22144 22144 22144 Actual result: -------------- 20720 21816 22144 ..... ..... ..... 16775400 16775728 16776056 16776384 Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 32 bytes) in /castle/hkmaly/programy/php/test_leak.php on line 6 -- Edit bug report at http://bugs.php.net/?id=30053&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30053&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30053&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30053&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30053&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30053&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30053&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30053&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30053&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30053&r=support Expected behavior: http://bugs.php.net/fix.php?id=30053&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30053&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30053&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30053&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30053&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30053&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30053&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30053&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30053&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30053&r=mysqlcfg