title: Difference in PerfView's GCStats and CollectionCount() results
body: <p>I'm learning PerfView and tried GCStats report.
  I've created a simple app which does a lot memory allocation on the heap:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  
  class Program
  {
      static void Main(string[] args)
      {
          GcReport();
          const int size = 10 * 1024 * 1024;
          var list = new List&lt;int&gt;();
          for (int i = 0; i &lt; size; i++)
          {
              list.Add(i);
          }
  
          for (int i = 0; i &lt; size; i++)
          {
              object obj1 = list[i];
              object obj2 = list[i];
  
              if (obj1 == obj2)
                  Console.WriteLine("Match found");
          }
  
          GcReport();  // &lt;-- results are shown below 
      }
  
      private static void GcReport()
      {
          Console.WriteLine($"Gen0: {GC.CollectionCount(0)}");
          Console.WriteLine($"Gen1: {GC.CollectionCount(1)}");
          Console.WriteLine($"Gen2: {GC.CollectionCount(2)}");
      }
  }
  </code></pre>
  
  <p>Here is how I configure Run dialog in PefrView:<a href="https://i.stack.imgur.com/Cl7l2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cl7l2.png" alt="enter image description here"></a></p>
  
  <p>Here is a PerfView's GCStats report:
  <a href="https://i.stack.imgur.com/6sDcN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6sDcN.png" alt="PerfView&#39;s GCStats report"></a></p>
  
  <p>And here is a peace of PerfView's log file, which shows results of second GcReport() method:
  <a href="https://i.stack.imgur.com/eYhfS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eYhfS.png" alt="enter image description here"></a></p>
  
  <p>As you can see, numbers of GC collections are different in PerfView's report and in Console Log results. Can somebody explain, why numbers are different?</p>