note 39217 added to function.create-function
| From: | neoatgothic-chatd0tde at rn2 dot php dot net | Date: | Wed, 21 Jan 2004 01:54:19 +0000 |
| Subject: | note 39217 added to function.create-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63914@lists.php.net to get a copy of this message | ||
Beware of memory-leaks, the garbage-collection seems to 'oversee' dynamically created
functions!
I used a function like this to replace special characters in links with their htmlentities:
<?php
$text = preg_replace_callback (
"/(<(frame src|a href|form action)=\")([^\"]+)(\"[^>]*>)/i",
create_function (
'$matches',
'return $matches[1] . htmlentities ($matches[3]) . $matches[4];'
),
$text);
?>
After 1000 calls, the process used about 5MB more than before. In my situation this boosted up the
memory-size of one PHP-process up to over 100MB!
In such cases, better store the function in a global variable.
----
Manual Page -- http://www.php.net/manual/en/function.create-function.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39217
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39217&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39217&report=yes
Search -- http://master.php.net/manage/user-notes.php