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 System.Runtime.GCSettings.LargeObjectHeapCompactionMode property to System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce before calling the GC.Collect method, as the following example illustrates.
code reference: System.Runtime.GCSettings#1