ID:               6333
 Comment by:       josh at mykoala dot com
 Reported By:      ewdafa at ewdafa dot b0rk dot co dot uk
 Status:           Closed
 Bug Type:         Performance problem
 Operating System: linux-2.2.16
 PHP Version:      4.0.1pl2
 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------

[2000-09-07 11:43:23] [EMAIL PROTECTED]

This isn't a bug but how it works. Each create_function() call creates
a new unique function. So obviously if you define zillions in an
infinite loop you'll run out of memory.

------------------------------------------------------------------------

[2000-08-24 09:57:38] 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);
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=6333&edit=1

Reply via email to