ID: 39010 Comment by: kexianbin at diyism dot com Reported By: djgrrr at gmail dot com Status: Open Bug Type: Feature/Change Request Operating System: * PHP Version: 5.1.6 New Comment:
You could write it like this: isset($fn)?$fn:$fn=create_function('$v', 'echo $v;'); Previous Comments: ------------------------------------------------------------------------ [2008-09-03 09:10:57] laysoft at gmail dot com My reproduction code: <? ini_set('display_errors',TRUE); ini_set('memory_limit','2M'); error_reporting(E_ALL); for ($i=0;$i<30000;$i++) { $func=create_function('$m','return($m);'); unset($func); echo '. '; } echo '<h1>OK</h1>'; ?> It breaks with "Fatal error: Allowed memory size of 2097152 bytes exhausted..." error. Is there any way, to solve this problem? ------------------------------------------------------------------------ [2006-10-01 15:29:35] djgrrr at gmail dot com Description: ------------ The PHP version is actually Irrelevant If you use create_function many times in a script to make lambda functions, it will use more and more memory. Now, I know that this is the expected result, but it would be really good to have a function like free_function or delete_function that could be used to remove the lambda functions, and free up the memory they use. Obviously this function would have to be limited to only lambda function, and it not be possible to use it on normal functions. Personally, I think this is VERY essential to the CLI version of PHP as many CLI PHP programs do not often restart, but keep running, simply rehashing its config and any modules (using lambda functions) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39010&edit=1