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. > > <?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
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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php