We mostly tend to following the above best practice.
Have a look at String vs StringBuilder
But StringBuilder could throw OutOfMemoryException even when there is sufficient memory available. It throws OOM exception because it needs "continuous block of memory".
Some links for reference
StringBuilder OutOfMemoryException
and there are many more.....
How many of you faced this problem or aware and what did you do to resolve it?
Is there anything I am missing?
P.S: I wasn't aware of this.
I have rephrased the question.
*** The same thing worked with manual concatenation(I'll verify this and update SO). The other thing that caused me concern was that there is enough memory in the system. That's the reason I raised this question here to check whether any one faced this problem or there was something drastically wrong with the code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…