|
-
Apr 18th, 2012, 08:02 PM
#1
Re: Replace function runs out of memory
Every one of those calls is creating a whole new string. Strings are immutable, so whenever you think you are changing one, you are actually abandoning it and creating a new one with the changes. Abandoning the one string doesn't remove it, and in your case, it almost certainly means that not only has it not been deleted, but it CAN'T be deleted, so the old string and the new string remain in memory. That is probably what is killing the memory. You are probably creating at least two, and possibly more, strings of the full size with each call to Replace.
As for what to do...on that I have no good idea as long as you can't come up with a way to work on parts of the string rather than the whole thing.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|