On 03/02/13 16:27, Hans-Juergen Petrich wrote: > The only different in the second example is the fixed body length of > the eval()-created anoymous function. > I wondering why the memory in the second code-example will be freed at > some point while in the first example not. > > I don't think it's a PHP-Bug but i also not understand this behavior. > > Is there one who can explain this? > Thank you very much. > > Greetings > Hans-Juergen Petrich
It can be simplified to: > <?php > while (true) { > $value = mt_rand(1, 10000); > $a = '$ano_fnc = function() {' . str_repeat(" ", $value) . '};'; > eval ($a); > echo "Mem usage: ".memory_get_usage()."\n"; > } The function *is* being removed, $ano_fnc alternates between object(Closure)#1 and object(Closure)#2, it's not leaking function objects. I suspect eval is checking a hashtable which is being forced to resize continuously, but it shouldn't grow unbounded either. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php