mscorlib(4.0.0.0) API with additions
|
Controls the system garbage collector, a service that automatically reclaims unused memory. More...
Public Member Functions | |
static int | GetGeneration (object obj) |
Returns the current generation number of the specified object. More... | |
Static Public Member Functions | |
static void | AddMemoryPressure (long bytesAllocated) |
Informs the runtime of a large allocation of unmanaged memory that should be taken into account when scheduling garbage collection. More... | |
static void | RemoveMemoryPressure (long bytesAllocated) |
Informs the runtime that unmanaged memory has been released and no longer needs to be taken into account when scheduling garbage collection. More... | |
static void | Collect (int generation) |
Forces an immediate garbage collection from generation 0 through a specified generation. More... | |
static void | Collect () |
Forces an immediate garbage collection of all generations. More... | |
static void | Collect (int generation, GCCollectionMode mode) |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value. More... | |
static void | Collect (int generation, GCCollectionMode mode, bool blocking) |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value, with a value specifying whether the collection should be blocking. More... | |
static void | Collect (int generation, GCCollectionMode mode, bool blocking, bool compacting) |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value, with values that specify whether the collection should be blocking and compacting. More... | |
static int | CollectionCount (int generation) |
Returns the number of times garbage collection has occurred for the specified generation of objects. More... | |
static void | KeepAlive (object obj) |
References the specified object, which makes it ineligible for garbage collection from the start of the current routine to the point where this method is called. More... | |
static int | GetGeneration (WeakReference wo) |
Returns the current generation number of the target of a specified weak reference. More... | |
static void | WaitForPendingFinalizers () |
Suspends the current thread until the thread that is processing the queue of finalizers has emptied that queue. More... | |
static void | SuppressFinalize (object obj) |
Requests that the common language runtime not call the finalizer for the specified object. More... | |
static void | ReRegisterForFinalize (object obj) |
Requests that the system call the finalizer for the specified object for which M:System.GC.SuppressFinalize(System.Object) has previously been called. More... | |
static long | GetTotalMemory (bool forceFullCollection) |
Retrieves the number of bytes currently thought to be allocated. A parameter indicates whether this method can wait a short interval before returning, to allow the system to collect garbage and finalize objects. More... | |
static void | RegisterForFullGCNotification (int maxGenerationThreshold, int largeObjectHeapThreshold) |
Specifies that a garbage collection notification should be raised when conditions favor full garbage collection and when the collection has been completed. More... | |
static void | CancelFullGCNotification () |
Cancels the registration of a garbage collection notification. More... | |
static GCNotificationStatus | WaitForFullGCApproach () |
Returns the status of a registered notification for determining whether a full, blocking garbage collection by the common language runtime is imminent. More... | |
static GCNotificationStatus | WaitForFullGCApproach (int millisecondsTimeout) |
Returns, in a specified time-out period, the status of a registered notification for determining whether a full, blocking garbage collection by the common language runtime is imminent. More... | |
static GCNotificationStatus | WaitForFullGCComplete () |
Returns the status of a registered notification for determining whether a full, blocking garbage collection by the common language runtime has completed. More... | |
static GCNotificationStatus | WaitForFullGCComplete (int millisecondsTimeout) |
Returns, in a specified time-out period, the status of a registered notification for determining whether a full, blocking garbage collection by common language the runtime has completed. More... | |
static bool | TryStartNoGCRegion (long totalSize) |
Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available. More... | |
static bool | TryStartNoGCRegion (long totalSize, long lohSize) |
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. More... | |
static bool | TryStartNoGCRegion (long totalSize, bool disallowFullBlockingGC) |
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. More... | |
static bool | TryStartNoGCRegion (long totalSize, long lohSize, bool disallowFullBlockingGC) |
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. More... | |
static void | EndNoGCRegion () |
Ends the no GC region latency mode. More... | |
Properties | |
static int | MaxGeneration [get] |
Gets the maximum number of generations that the system currently supports. More... | |
Controls the system garbage collector, a service that automatically reclaims unused memory.
|
static |
Informs the runtime of a large allocation of unmanaged memory that should be taken into account when scheduling garbage collection.
bytesAllocated | The incremental amount of unmanaged memory that has been allocated. |
T:System.ArgumentOutOfRangeException | bytesAllocated is less than or equal to 0.-or-On a 32-bit computer, bytesAllocated is larger than F:System.Int32.MaxValue. |
|
static |
Cancels the registration of a garbage collection notification.
T:System.InvalidOperationException | This member is not available when concurrent garbage collection is enabled. See the <gcConcurrent> runtime setting for information about how to disable concurrent garbage collection. |
|
static |
|
static |
|
static |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value.
generation | The number of the oldest generation to be garbage collected. |
mode | An enumeration value that specifies whether the garbage collection is forced (F:System.GCCollectionMode.Default or F:System.GCCollectionMode.Forced) or optimized (F:System.GCCollectionMode.Optimized). |
T:System.ArgumentOutOfRangeException | generation is not valid.-or- mode is not one of the T:System.GCCollectionMode values. |
|
static |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value, with a value specifying whether the collection should be blocking.
generation | The number of the oldest generation to be garbage collected. |
mode | An enumeration value that specifies whether the garbage collection is forced (F:System.GCCollectionMode.Default or F:System.GCCollectionMode.Forced) or optimized (F:System.GCCollectionMode.Optimized). |
blocking | true to perform a blocking garbage collection; false to perform a background garbage collection where possible. |
T:System.ArgumentOutOfRangeException | generation is not valid.-or- mode is not one of the T:System.GCCollectionMode values. |
|
static |
Forces a garbage collection from generation 0 through a specified generation, at a time specified by a T:System.GCCollectionMode value, with values that specify whether the collection should be blocking and compacting.
generation | The number of the oldest generation to be garbage collected. |
mode | An enumeration value that specifies whether the garbage collection is forced (F:System.GCCollectionMode.Default or F:System.GCCollectionMode.Forced) or optimized (F:System.GCCollectionMode.Optimized). |
blocking | true to perform a blocking garbage collection; false to perform a background garbage collection where possible. See the Remarks section for more information. |
compacting | true to compact the small object heap; false to sweep only. See the Remarks section for more information. |
|
static |
Returns the number of times garbage collection has occurred for the specified generation of objects.
generation | The generation of objects for which the garbage collection count is to be determined. |
T:System.ArgumentOutOfRangeException | generation is less than 0. |
|
static |
Ends the no GC region latency mode.
T:System.InvalidOperationException | The garbage collector is not in no GC region latency mode. See the Remarks section for more information. -or-The no GC region latency mode was ended previously because a garbage collection was induced. -or-A memory allocation exceeded the amount specified in the call to the M:System.GC.TryStartNoGCRegion(System.Int64) method. |
static int System.GC.GetGeneration | ( | object | obj | ) |
Returns the current generation number of the specified object.
obj | The object that generation information is retrieved for. |
|
static |
Returns the current generation number of the target of a specified weak reference.
wo | A T:System.WeakReference that refers to the target object whose generation number is to be determined. |
T:System.ArgumentException | Garbage collection has already been performed on wo . |
|
static |
Retrieves the number of bytes currently thought to be allocated. A parameter indicates whether this method can wait a short interval before returning, to allow the system to collect garbage and finalize objects.
forceFullCollection | true to indicate that this method can wait for garbage collection to occur before returning; otherwise, false . |
|
static |
|
static |
Specifies that a garbage collection notification should be raised when conditions favor full garbage collection and when the collection has been completed.
maxGenerationThreshold | A number between 1 and 99 that specifies when the notification should be raised based on the objects allocated in generation 2. |
largeObjectHeapThreshold | A number between 1 and 99 that specifies when the notification should be raised based on objects allocated in the large object heap. |
T:System.ArgumentOutOfRangeException | maxGenerationThreshold or largeObjectHeapThreshold is not between 1 and 99. |
|
static |
Informs the runtime that unmanaged memory has been released and no longer needs to be taken into account when scheduling garbage collection.
bytesAllocated | The amount of unmanaged memory that has been released. |
T:System.ArgumentOutOfRangeException | bytesAllocated is less than or equal to 0. -or- On a 32-bit computer, bytesAllocated is larger than F:System.Int32.MaxValue. |
|
static |
Requests that the system call the finalizer for the specified object for which M:System.GC.SuppressFinalize(System.Object) has previously been called.
obj | The object that a finalizer must be called for. |
T:System.ArgumentNullException | obj is null . |
|
static |
|
static |
Attempts to disallow garbage collection during the execution of a critical path if a specified amount of memory is available.
totalSize | The amount of memory in bytes to allocate without triggering a garbage collection. It must be less than or equal to the size of an ephemeral segment. For information on the size of an ephemeral segement, see the "Ephemeral generations and segments" section in the Fundamentals of Garbage Collection article. |
true
if the runtime was able to commit the required amount of memory and the garbage collector is able to enter no GC region latency mode; otherwise, false
. T:System.ArgumentOutOfRangeException | totalSize exceeds the ephemeral segment size. |
T:System.InvalidOperationException | The process is already in no GC region latency mode. |
|
static |
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.
totalSize | The amount of memory in bytes to allocate without triggering a garbage collection. totalSize –lohSize must be less than or equal to the size of an ephemeral segment. For information on the size of an ephemeral segement, see the "Ephemeral generations and segments" section in the Fundamentals of Garbage Collection article. |
lohSize | The number of bytes in totalSize to use for large object heap (LOH) allocations. |
true
if the runtime was able to commit the required amount of memory and the garbage collector is able to enter no GC region latency mode; otherwise, false
. T:System.ArgumentOutOfRangeException | totalSize – lohSize exceeds the ephemeral segment size. |
T:System.InvalidOperationException | The process is already in no GC region latency mode. |
|
static |
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.
totalSize | The amount of memory in bytes to allocate without triggering a garbage collection. It must be less than or equal to the size of an ephemeral segment. For information on the size of an ephemeral segement, see the "Ephemeral generations and segments" section in the Fundamentals of Garbage Collection article. |
disallowFullBlockingGC | true to omit a full blocking garbage collection if the garbage collector is initially unable to allocate totalSize bytes; otherwise, false . |
true
if the runtime was able to commit the required amount of memory and the garbage collector is able to enter no GC region latency mode; otherwise, false
. T:System.ArgumentOutOfRangeException | totalSize exceeds the ephemeral segment size. |
T:System.InvalidOperationException | The process is already in no GC region latency mode. |
|
static |
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.
totalSize | The amount of memory in bytes to allocate without triggering a garbage collection. totalSize –lohSize must be less than or equal to the size of an ephemeral segment. For information on the size of an ephemeral segement, see the "Ephemeral generations and segments" section in the Fundamentals of Garbage Collection article. |
lohSize | The number of bytes in totalSize to use for large object heap (LOH) allocations. |
disallowFullBlockingGC | true to omit a full blocking garbage collection if the garbage collector is initially unable to allocate the specified memory on the small object heap (SOH) and LOH; otherwise, false . |
true
if the runtime was able to commit the required amount of memory and the garbage collector is able to enter no GC region latency mode; otherwise, false
. T:System.ArgumentOutOfRangeException | totalSize – lohSize exceeds the ephemeral segment size. |
T:System.InvalidOperationException | The process is already in no GC region latency mode. |
|
static |
|
static |
Returns, in a specified time-out period, the status of a registered notification for determining whether a full, blocking garbage collection by the common language runtime is imminent.
millisecondsTimeout | The length of time to wait before a notification status can be obtained. Specify -1 to wait indefinitely. |
T:System.ArgumentOutOfRangeException | millisecondsTimeout must be either non-negative or less than or equal to F:System.Int32.MaxValue or -1. |
|
static |
|
static |
Returns, in a specified time-out period, the status of a registered notification for determining whether a full, blocking garbage collection by common language the runtime has completed.
millisecondsTimeout | The length of time to wait before a notification status can be obtained. Specify -1 to wait indefinitely. |
T:System.InvalidOperationException | millisecondsTimeout must be either non-negative or less than or equal to F:System.Int32.MaxValue or -1. |
|
static |
|
staticget |