ID: 36672 Comment by: intersect at gmail dot com Reported By: treehousetim at gmail dot com Status: No Feedback Bug Type: Scripting Engine problem Operating System: Windows PHP Version: 5.1.2 New Comment:
Exists on 5.2.4 on Linux. Reproduce with the following code: $ cat TestMem.php <?php $counter=0; echo "Loop that does something..\n"; for($c=0;$c<1000000;$c++) { if(MyFunc()) { echo "."; } } echo "\nLoop that does nothing..\n"; $counter=0; for($c=0;$c<1000000;$c++) { if(MyFunc()) { } } function MyFunc() { global $counter; if(($counter % 100000) === 0) { echo "$counter:" . memory_get_usage() . "\n"; } $counter++; return(false); } ?> Results: $ php TestMem.php Loop that does something.. 0:58216 100000:58216 200000:58256 300000:58256 400000:58256 500000:58256 600000:58256 700000:58256 800000:58256 900000:58256 Loop that does nothing.. 0:58256 100000:4058244 200000:8058244 300000:12058244 400000:16058244 500000:20058244 600000:24058244 700000:28058244 800000:32058244 900000:36058244 Note that memory leak results are identical if a 'slightly' non-empty loop (ie: if($blah) { 1; } ) is included instead. Leigh. Previous Comments: ------------------------------------------------------------------------ [2006-03-17 01:00:05] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2006-03-09 20:44:14] m...@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.1-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.1-win32-latest.zip Not reproducible on Linux. ------------------------------------------------------------------------ [2006-03-09 16:01:17] treehousetim at gmail dot com Description: ------------ Empty if that calls a function that returns a value causes php to consume huge amounts of memory (at least under windows) This was tested using CLI Reproduce code: --------------- function testIt() { return true; } for ( $ix = 0; $ix < 200000; $ix++ ) { echo "Jere is the Memory King $ix" . NL; if ( testIt() ) { } } Expected result: ---------------- php's memory usage to remain somewhat stable. Actual result: -------------- php's memory usage goes up at the rate of about one meg per second while this script is running. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36672&edit=1