I am working on c#. I want know how i can free the stringbuilder n byte[]….Because I am getting an out of memory exception while using string builder….
Another thing is String.Replace() is also giving an out of memory exception or else is there any other way to do the same….please tell me how I can overcome these problems…
thanks in advance
I am working on c#. I want know how i can free the stringbuilder
Share
How big a string are you building? Do you know how big it will be up-front? If so set the Capacity of the StringBuilder.
If you don’t do this it starts off with capacity of 16 and then doubles it each time you break through that limit. Capacity will go 16, 32, 64, 128.
Each time it does this it is likely to need to reallocate memory.
If the data is that big is it better to build it in a file stream rather than a StringBuilder?