title: GC.Collect and multithreading in C#
body: <p>I am using C# 3.5 and the reactive extension supporting TPL in C# version before 4.</p>
  
  <p>My application calls GC.Collect() in several places (yes, I know that I should not manually call this method but please leave this point alone for at least this question). Before I put multithreading implementation in, it works fine. GC.Collect() is called in each of the thread so it is called in a multithreading context.</p>
  
  <p>Then I use the Task to implement multithreading and I found that after the application running for a while and the memory usage increases, the threads stop working properly. I declare "the threads stop working properly" from the scenario that the CPU usage on a multi-core computer drops to single-thread level, rather than fully utilized.</p>
  
  <p>When I attempted to tackle this problem, the only thing I did was to comment out the GC.Collect() call and this change makes the threads working fine. I would like to turn GC.Collect() off unless when I run something big in my application, without GC.Collect(), I will run into OutOfMemory exception. This is the reason I keep the call.</p>
  
  <p>Now could anyone explain why GC.Collect() being called in a multithreading context on a machine using high memory causes multithreading problem? Is there any related theory on this bit? Thank you very much for the answer.</p>