Ok, I am no C coder and I don't claim to be very smart about low level
parts of PHP. But, IMO, this is bug.
http://bugs.php.net/bug.php?id=36924
I have created a test script that shows the insanity of this bug:
<?php
$str = "This is a medium length string";
$start = memory_get_usage();
for($x=1;$x<=100;$x++){
echo $str.": (3.5): ".time()."\n";
}
$first_growth = number_format(memory_get_usage() - $start);
$start = memory_get_usage();
for($x=1;$x<=100;$x++){
echo "$str: (3.5): ".time()."\n";
}
$growth = number_format(memory_get_usage() - $start);
echo "first growth: $first_growth\nsecond growth: $growth\n";
?>
Now, you turn that into a script that is going to loop millions of
times, building strings to build data and run for hours. The next thing
you know, your cron job is using 450MB of memory and you try to figure
out what YOU did wrong. Hours later you find this little jewel waiting
for you and realize you did not do anything wrong. You just used the
language.
Everyone ignored my last email about memory waste and large arrays. I
can only assume that you will ignore this one too. I am starting to see
why Stefan became so bitter.
I have always tried to squash the "myth" that putting variables inside
strings in PHP was bad, but now, I think I will flip on that.
I tested as far back as PHP 4.3.9 and as new as 5.2.1.
--
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