Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:65572 php.internals:65573 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75271 invoked from network); 3 Feb 2013 15:27:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2013 15:27:41 -0000 X-Host-Fingerprint: 195.42.115.214 de.p44.net Received: from [195.42.115.214] ([195.42.115.214:20553] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/00-09403-BE18E015 for ; Sun, 03 Feb 2013 10:27:39 -0500 To: internals@lists.php.net,"PHP internals" Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Date: Sun, 03 Feb 2013 22:27:16 +0700 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: User-Agent: Opera Mail/12.12 (Win32) X-Posted-By: 195.42.115.214 Subject: (non)growing memory while creating anoymous functions via eval() From: petrich@tronic-media.com ("Hans-Juergen Petrich") Hi all In this example (using php-5.4.11 on Linux) the memory will grow non-stop: for ( $fp = fopen('/dev/urandom', 'rb'); true;) { eval ('$ano_fnc = function() {$x = "'.bin2hex(fread($fp, mt_rand(1, 10000))).'";};'); echo "Mem usage: ".memory_get_usage()."\n"; } But in this example not: for ( $fp = fopen('/dev/urandom', 'rb'); true;) { eval ('$ano_fnc = function() {$x = "'.bin2hex(fread($fp, 10000)).'";};'); echo "Mem usage: ".memory_get_usage()."\n"; } 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