Question on Garbage Collection

From: Prasanna Padmanabhan (prasannap_at_citrix.nospam.com)
Date: 10/19/04


Date: Tue, 19 Oct 2004 19:31:41 -0400

In a simple .NET application, I create a Hashtable that add 1000 entries to
it.
In Task Manager, the memory usage for the .NET process spikes up
(understandably).

I now remove all the 1000 entries from the Hashtable. The memory usage does
not
go down. I understand this also. This is because the GC has not run yet.

But my question is, when does GC run again? I did notice that when I start a
heavyweight
app like VS 2003, the memory usage of my original app went down!

So it is as if GC ran at that point, collected and compacted all the unused
garbage memory
and gave it back to the system. Right?

Also, is the GC a thread? If so, in whose process space does it run? Is is
per .NET process
or just one unique GC thread for the entire system?

Prasanna



Relevant Pages