GC.TryStartNoGCRegion Method

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Attempts to disallow garbage collection during the execution of a critical path.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticTryStartNoGCRegion(Int64)

Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available.

System_CAPS_pubmethodSystem_CAPS_staticTryStartNoGCRegion(Int64, Boolean)

Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available, and controls whether the garbage collector does a full blocking garbage collection if not enough memory is initially available.

System_CAPS_pubmethodSystem_CAPS_staticTryStartNoGCRegion(Int64, Int64)

Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available for the large object heap and the small object heap.

System_CAPS_pubmethodSystem_CAPS_staticTryStartNoGCRegion(Int64, Int64, Boolean)

Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available for the large object heap and the small object heap, and controls whether the garbage collector does a full blocking garbage collection if not enough memory is initially available.

System_CAPS_importantImportant

You cannot nest calls to the TryStartNoGCRegion method, and you should only call the EndNoGCRegion method if the runtime is currently in no GC region latency mode. In other words, you should not call TryStartNoGCRegion multiple times (after the first method call, subsequent calls will not succeed), and you should not expect calls to EndNoGCRegion to succeed just because the first call to TryStartNoGCRegion succeeded.

Return to top
Show: