Re: The way the engine works?

From: Date: Mon, 05 Mar 2007 22:54:39 +0000
Subject: Re: The way the engine works?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-28251@lists.php.net to get a copy of this message
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. <?php $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 -- Brian Moon ------------- http://dealnews.com/ It's good to be cheap =)

« previous php.internals (#28251) next »