Insane System.String Memory usage

  • Thread starter Thread starter Zach Tong
  • Start date Start date
Z

Zach Tong

I recently ran our code through a profiler to determine why it was
using so much memory. It turns out the System.String object is taking
95% of the memory. We have considered converting the strings to
StringBuilder objects, but I don't think this will help. From what I
understand, the StringBuilder only helps with speed increases (by
reducing time to create a new string). In addition to that, most of
the string manipulations are very small/short.

It seems like the System.String objects are not getting released. Any
idea why? Any tips to reduce the memory usage? Thanks.
 
Zach,
It seems like the System.String objects are not getting released. Any
idea why? Any tips to reduce the memory usage? Thanks.
It really depends on how & what you are doing with the strings. Without
seeing your code, or a small sampling of your typical code, I'm not sure any
one here can really answer your question.
From what I
understand, the StringBuilder only helps with speed increases (by
reducing time to create a new string).
It reduces the time by avoiding creating a new string altogether, Remember
if you avoid creating a new string, then you reduce the memory that
System.String uses. It really depends on how & why you are creating new
strings if StringBuilder will help or not.

Hope this helps
Jay
 
They aren't released as long as you hold a reference to it. Without seeing
any code it's hard to tell why references are held.
I suggest you post a complete sample that illustrate your findings.

Willy.
 
Back
Top