コード例 #1
0
 /// <summary>Forces an immediate garbage collection from generation zero through a specified generation.</summary>
 /// <param name="generation">The number of the oldest generation that garbage collection can be performed on. </param>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///   <paramref name="generation" /> is not valid. </exception>
 /// <filterpriority>1</filterpriority>
 public static void Collect(int generation)
 {
     if (generation < 0)
     {
         throw new ArgumentOutOfRangeException("generation");
     }
     GC.InternalCollect(generation);
 }
コード例 #2
0
 /// <summary>Forces an immediate garbage collection of all generations. </summary>
 /// <filterpriority>1</filterpriority>
 public static void Collect()
 {
     GC.InternalCollect(GC.MaxGeneration);
 }