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 =)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to