The call to GC.Collect() is needed for the Assembly of objects in the 1 and 2 generations. The fact that in the 0 generation is going so well. But what is going through the 0-the first generation, i.e. objects in the 1st and 2nd generations, very rarely receive the attention of the collector, if there is no hard pressure on the memory. Thus, very large objects, including arrays, when you create a placed immediately in a heap in the 2nd generation.
Accordingly, you need to match:
1) In the program there is some operation that creates a very large object, so that it immediately falls into the 2nd generation.
2) Free memory on the server is no more, or very little.
3) you Need to avoid down-time associated with garbage collection, when running following such an operation.
4) At some point of the program is similarly to ensure that there is no reference to the large object (otherwise GC will not delete it)
And only then you can pull GC.Collect(). Otherwise, the meaning of cause it is not.
Ie you a hundred percent sure that there will be a delay caused by garbage collection, and exactly what the collector is going to clean the 1st and 2nd generation, but you do not like something when it happens this delay, and you move it to an earlier time (perhaps more appropriate/acceptable) forced call to GC.Collect().
The main thing you need to understand that GC.Collect() magically does not clear the memory. To make this challenge something cleaned you need to be 100% sure that the memory objects are not referenced, but are stuck in memory. In other words, there are no memory leaks. (Yes, Yes, programs on the dot.there also can flow) generally, if you fix the leak, i.e., to build the correct memory, then the need of enforcing the garbage collector will disappear by itself.