|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-08-24 09:57 UTC] ewdafa at ewdafa dot b0rk dot co dot uk
the following code causes PHP to continually eat more and more memory where it should be destroying the old reference for $func.
while(1) {
$array = array();
$func = create_function('', "return 0;");
$array[] = $func;
$func = 0;
echo "sleeping for a second.\n";
sleep(1);
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 15:00:02 2025 UTC |
It's been said that this is just how the function works, but it seems as though destroying allocations for an anonymous function when redefining to the same variable would be the way to handle it. Example: for ($i=0; $i<10; $i++) { $echoit = create_function('$wha', 'echo $wha;'); echo memory_get_usage(); $echoit(" on iteration: #$i\n"); } How else can you dynamically modify function or code without reloading a script?