jeudi 2 avril 2015

Memory consumed by String and StringBuilder is duplicate

I need to concatinate few strings. I am using StringBuilder for that as below



StringBuilder result = new StringBuilder(length);


The length is the "length" of the string that i want at the end.


"Length" is of higher number. To get string i need to do



return result.ToString();


When i am trying to analyze memory consumed by my application i see that "StringBuilder" and "String" are taking same amount of memory and its duplicate. As the length of the string is long, its occupying larger % of memory.


Is there a better way to solve this memory problem?


Aucun commentaire:

Enregistrer un commentaire