Ok, I\'ve read a couple of topics about it, but here it goes. Let\'s imagine I have an application where basically every now and then I will click on a button, a lot of thin
I'm hoping you're aware that calling GC.Collect doesn't cause more (or less) objects to be collected.
If you're trying to optimize for time, do you know the time GC takes to collect objects in your application? On desktop operating systems (XP, Vista etc..), the CLR uses a concurrent GC, and it can run without suspending all threads in the application for the duration of the collection.
Explicitly calling GC.Collect is not recommended because
It throws the CLR GC Tuning algorithm out of gear. The tuner determines when to trigger a GC automatically, and forcing a manual GC messes with its calculations.
By forcing a collection manually, you can end up promoting objects up a generation - objects which might have been collected in the next GC ( if they were "orphaned" before the GC decided to kick in).
You might find it interesting that .NET 4.0, a GC notification mechanism has been introduced for these kinds of scenarios.