Use this method to try to reclaim all memory that is inaccessible. It performs a blocking garbage collection of all generations.
All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected. Use this method to force the system to try to reclaim the maximum amount of available memory.
Starting with the net_v451, you can compact the large object heap (LOH) by setting the GCSettings.LargeObjectHeapCompactionMode property to GCLargeObjectHeapCompactionMode.CompactOnce before calling the GC.Collect method, as the following example illustrates.
code reference: System.Runtime.GCSettings#1
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 188.8.131.52, 184.108.40.206