title: How can I choose parameters for GC.RegisterForFullGCNotification?
body: <p>If you want to receive GC notifications (for example, to transfer load between nodes during collection), then you can use the trio of methods, <code>GC.RegisterForFullGCNotification</code>, <code>GC.WaitForFullGCApproach</code> and <code>GC.WaitForFullGCComplete</code> - however, the parameters passed to <code>GC.RegisterForFullGCNotification</code> seem largely to be meaningless, and no <em>real world</em> guidance is given on how to choose suitable values. There are vague notes, like <a href="http://msdn.microsoft.com/en-us/library/system.gc.registerforfullgcnotification.aspx" rel="noreferrer">from here</a>:</p>
  
  <blockquote>
    <p>Use the following guidelines for specifying the maxGenerationThreshold
    and largeObjectHeapThreshold parameters:</p>
    
    <p>The larger the threshold value, the further away in time the
    collection will likely occur and the sooner the notification will be
    raised.</p>
    
    <p>A larger threshold value provides more opportunities for the runtime
    to check for an approaching collection. This increases the likelihood
    that you will be notified. However, you should not set the threshold
    too high because that results in a longer wait before the runtime
    induces the next collection.</p>
    
    <p>When you induce a collection yourself upon notification using a high
    threshold value, more objects are reclaimed than would be reclaimed by
    the runtime's next collection.</p>
    
    <p>The smaller the threshold value, the greater the likelihood that a
    collection will occur sooner and the notification will be raised
    later.</p>
  </blockquote>
  
  <p>or <a href="http://msdn.microsoft.com/en-us/library/cc713687.aspx" rel="noreferrer">from here</a></p>
  
  <blockquote>
    <p><code>maxGenerationThreshold</code> A number between 1 and 99 that specifies when
    the notification should be raised based on the objects promoted in
    generation 2.</p>
    
    <p><code>largeObjectHeapThreshold</code> A number between 1 and 99 that
    specifies when the notification should be raised based on the objects
    that are allocated in the large object heap.</p>
    
    <p>If you specify a value
    that is too high, there is a high probability that you will receive a
    notification, but it could be too long a period to wait before the
    runtime causes a collection. If you induce a collection yourself, you
    may reclaim more objects than would be reclaimed if the runtime causes
    the collection.</p>
    
    <p>If you specify a value that is too low, the runtime may cause the
    collection before you have had sufficient time to be notified.</p>
  </blockquote>
  
  <p>However, that doesn't really help me choose sensible / correct numbers, except "not too high, not too low".</p>
  
  <p>Currently, I'm just using one of the few provided examples, i.e.</p>
  
  <pre><code>// these are magic numbers; nobody really knows what they mean...
  GC.RegisterForFullGCNotification(10, 10);
  </code></pre>
  
  <p>but... it is very unclear whether <code>10</code>,<code>10</code> is a correct choice, an arbitrary choice, or how I should change this to reflect any particular usage scenario.</p>
  
  <p>So: is there any <em>correct</em> way of choosing these numbers? Or is it just trial-and-error, based on whether I'm getting the events too early/late?</p>