Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28253 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12540 invoked by uid 1010); 5 Mar 2007 23:00:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12512 invoked from network); 5 Mar 2007 23:00:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2007 23:00:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from [204.11.219.139] ([204.11.219.139:46859] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/F7-16561-B11ACE54 for ; Mon, 05 Mar 2007 18:00:45 -0500 Received: from [207.126.233.18] (rasmus2.corp.yahoo.com [207.126.233.18]) (authenticated bits=0) by lerdorf.com (8.13.8/8.13.8/Debian-3) with ESMTP id l25N0boH020130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 5 Mar 2007 15:00:37 -0800 Message-ID: <45ECA114.3080402@lerdorf.com> Date: Mon, 05 Mar 2007 15:00:36 -0800 User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: Brian Moon CC: internals@lists.php.net References: <45EC8CE9.8020807@dealnews.com> <45EC9D1B.6000804@zend.com> <45EC9FAF.2080005@dealnews.com> In-Reply-To: <45EC9FAF.2080005@dealnews.com> X-Enigmail-Version: 0.94.2.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.90.1/2736/Mon Mar 5 10:55:43 2007 on colo X-Virus-Status: Clean Subject: Re: [PHP-DEV] The way the engine works? From: rasmus@lerdorf.com (Rasmus Lerdorf) Brian Moon wrote: > Antony Dovgal wrote: >> Yup, the language stole ~32Kb of your memory and used it to speedup >> the allocation of small chunks. > > Ok, in my attempt to send a sane looking example, I cleaned up the problem. > > > $str = "This is a medium length string"; > > $start = memory_get_usage(); > for($x=1;$x<=1000000;$x++){ > $var = $str." ".$x.": (3.5): ".time()."\n"; > } > $first_growth = number_format(memory_get_usage() - $start); > > $start = memory_get_usage(); > for($x=1;$x<=1000000;$x++){ > $var = "$str $x: (3.5): ".time()."\n"; > } > $growth = number_format(memory_get_usage() - $start); > > > echo "first growth: $first_growth\nsecond growth: $growth\n"; > > ?> > > The introduction of $x into the string makes the difference. > > first growth: 892 > second growth: 3,955,068 I get: first growth: 704 second growth: 32,264 with current PHP_5_2 checkout. I don't have a 5.1.x handy with memory limits compiled in. -Rasmus