I'm facing with a very strange behaviour. With this dummy code:
static void Main( string[] args )
{
int i = 0;
while ( true )
{
i++;
String giro = "iteration " + i;
Console.WriteLine(giro);
Thread.Sleep(40);
}
}
Using perfom the private bytes are increasing.
img http://dl.dropbox.com/u/2478017/memory.gif
How is it possible?
I thought GC takes care of these stuffs.
Moreover, if I compare memory behavior of this with a version in which i force GC collection every 10 iterations, the result is (for me) surprising:
The green process is the one with no GC.COllect(), and black one is the other.
Could you help me to understand the issue?
Thanks!
You're creating a bunch of strings. The GC hasn't seen fit to collect them yet. Eventually the memory graph will plateau. The GC works fine - there's no problems here :)
The GC doesn't tidy up memory straightaway. That would be very inefficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With