Re: StringBuilder vs. String performance
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 21 Apr 2006 19:20:57 +0100
Kevin Spencer <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I should have said "the most important point." I was quoting the previous
message. The predominant problems that occur with strings are centered
around memory accumulation. Speed is certainly a consideration, but not
likely to bring the app to a crashing halt, and not as much of an issue
unless there is a heck of a lot of string-building going on, in which case
memory is more likely to cause real problems.
Using string concatenation badly will cause a lot of GC work, but it
shouldn't actually bring the app to a crashing halt. With the typical
"append in a loop" which is what StringBuilder is usually the cure for,
each string is eligible for GC after a single extra iteration of the
loop, so although lots of gen0 strings are created, it shouldn't be an
issue. If the strings go into the large object heap, that's a different
matter - but then StringBuilder will have a similar problem, just less
pronounced.
Pretty much every question I've answered with a reply of "use
StringBuilder instead" has been due to someone complaining about speed,
not memory.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: StringBuilder vs. String performance
- From: Kevin Spencer
- Re: StringBuilder vs. String performance
- References:
- StringBuilder vs. String performance
- From: Richard Lewis Haggard
- Re: StringBuilder vs. String performance
- From: Kevin Spencer
- Re: StringBuilder vs. String performance
- From: Jon Skeet [C# MVP]
- Re: StringBuilder vs. String performance
- From: Kevin Spencer
- StringBuilder vs. String performance
- Prev by Date: ToolTip.Show(..), where?
- Next by Date: Re: StringBuilder vs. String performance
- Previous by thread: Re: StringBuilder vs. String performance
- Next by thread: Re: StringBuilder vs. String performance
- Index(es):
Relevant Pages
|