Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:28:50+00:00 2026-06-13T07:28:50+00:00

If you want to receive GC notifications (for example, to transfer load between nodes

  • 0

If you want to receive GC notifications (for example, to transfer load between nodes during collection), then you can use the trio of methods, GC.RegisterForFullGCNotification, GC.WaitForFullGCApproach and GC.WaitForFullGCComplete – however, the parameters passed to GC.RegisterForFullGCNotification seem largely to be meaningless, and no real world guidance is given on how to choose suitable values. There are vague notes, like from here:

Use the following guidelines for specifying the maxGenerationThreshold
and largeObjectHeapThreshold parameters:

The larger the threshold value, the further away in time the
collection will likely occur and the sooner the notification will be
raised.

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.

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.

The smaller the threshold value, the greater the likelihood that a
collection will occur sooner and the notification will be raised
later.

or from here

maxGenerationThreshold A number between 1 and 99 that specifies when
the notification should be raised based on the objects promoted in
generation 2.

largeObjectHeapThreshold 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.

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.

If you specify a value that is too low, the runtime may cause the
collection before you have had sufficient time to be notified.

However, that doesn’t really help me choose sensible / correct numbers, except “not too high, not too low”.

Currently, I’m just using one of the few provided examples, i.e.

// these are magic numbers; nobody really knows what they mean...
GC.RegisterForFullGCNotification(10, 10);

but… it is very unclear whether 10,10 is a correct choice, an arbitrary choice, or how I should change this to reflect any particular usage scenario.

So: is there any correct way of choosing these numbers? Or is it just trial-and-error, based on whether I’m getting the events too early/late?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:28:52+00:00Added an answer on June 13, 2026 at 7:28 am

    The best answer I could find on picking these parameters can be found in http://assets.red-gate.com/community/books/assets/Under_the_Hood_of_.NET_Management.pdf

    You may be wondering about the magic constants in the call to
    RegisterForFullGC Notification. This method takes two parameters,
    maxGenerationThreshold and largeObjectHeapThreshold. Both parameters
    can be integers between 1 and 99. Larger values for these parameters
    will cause the notification to be raised earlier, and smaller values
    will cause the notification to be raised closer to when the event
    actually takes place.

    The first parameter allows you to specify that
    you want to be notified based on the number of objects that have
    survived to Generation 2, and the second parameter specifies that you
    want to be notified based on the size of the Large Object Heap.
    However, neither parameter specifies an absolute value, so passing in
    30 for the maxGenerationThreshold does not imply triggering a
    Notification when there are 30 objects in Generation 2; it simply
    means that you want to be notified earlier than if you had passed in a
    value of 10. Unless you are specifically more interested in one
    trigger over the other, you may want to pass in the same value for
    each parameter, as this will help ensure that you are notified at the
    same stage, regardless of the trigger.

    A larger value will give you
    more time to deal with memory pressure, but you just need to be
    careful not to set it too high. The higher you set the thresholds, the
    quicker you get notified but the longer you have to wait on the GC.
    Play with these parameters in your application to see what works best
    for your load and the types of objects consuming your memory.

    So in answer, based on the above, it largely is trial and error however the two values you use for each parameter are likely to be the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my app to receive notifications from an external server, like Urban Airship
I want to receive notifications on fail of cron job on external server. I
I want to receive email to my email address through my asp.net application. Its
I want to receive rows as dictionaries in pymssql. in python-idle i ran: >>>
The user does not want to receive the approval emails in Salesforce. Is there
I have a form with: Check this if you Want to receive our newsletter:
i developed client server program using c++,so i want to receive more than 500kb
So basically, I'm posting data with wp_remote_post, and I want to receive sent data
I want users to receive 'points' for completing various tasks in my application -
I want something that will receive me the processes details, like I receive with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.