Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65574 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80947 invoked from network); 3 Feb 2013 16:30:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2013 16:30:29 -0000 Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.179 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.179 mail-we0-f179.google.com Received: from [74.125.82.179] ([74.125.82.179:58048] helo=mail-we0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/D0-09403-5A09E015 for ; Sun, 03 Feb 2013 11:30:29 -0500 Received: by mail-we0-f179.google.com with SMTP id x43so4289826wey.10 for ; Sun, 03 Feb 2013 08:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=5p8W4VuAtHtkPgaDcXDONXKvcqSvn6fCX8+JR8OX8Aw=; b=BAKvQV6I+Sm2vQ/cHcldjT6xUpBpwOBKSoeDDXvaO+FiLtQSDkBP6f19dcXAfqvXg7 gCb2lv8PVQWQ2MSjNB7g2XvFPmHk21cLXAUbZHgrAt/kv4RDiOZX3/wSCZrvSnEAdMWl KEofPUgUbE+uyv9iVDlz+G7vAh2+2DwY0aSUfixxBXI2NX8wBm9RIP5T6+WDzG3EuHBc FTlXQyv7bIHkzn9k2C4gKPX3ZYO6YKHdSR5gdPIt2E+X0aUD/hNHUbk+xuCbmZrP5vXz E0GEE6oLx1c+EHD3rkugMbTUH2OGXyqdNcWLyAlJr/bdT786wj87bWQ1BtvokQqL8LIz 0vqA== X-Received: by 10.180.84.162 with SMTP id a2mr6198824wiz.14.1359909026342; Sun, 03 Feb 2013 08:30:26 -0800 (PST) Received: from [192.168.1.26] (210.Red-193-153-87.dynamicIP.rima-tde.net. [193.153.87.210]) by mx.google.com with ESMTPS id s10sm16460585wiw.4.2013.02.03.08.30.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 03 Feb 2013 08:30:25 -0800 (PST) Message-ID: <510E9031.9040209@gmail.com> Date: Sun, 03 Feb 2013 17:28:33 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Hans-Juergen Petrich CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] (non)growing memory while creating anoymous functions via eval() From: keisial@gmail.com (=?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?=) 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: > 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.