Show / Hide Table of Contents

Class GCNotification

Provides a way to receive notifications from Garbage Collector asynchronously.

Inheritance
object
GCNotification
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public abstract class GCNotification

Methods

| Edit this page View Source

And(GCNotification)

Combines two filters using logical AND.

Declaration
public virtual GCNotification And(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

| Edit this page View Source

ExclusiveOr(GCNotification)

Combines two filters using logical XOR.

Declaration
public virtual GCNotification ExclusiveOr(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

| Edit this page View Source

GCTriggered()

Creates a filter that triggers notification on every GC occurred.

Declaration
public static GCNotification GCTriggered()
Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

GCTriggered(int)

Creates a filter that allows to detect garbage collection of the specified generation.

Declaration
public static GCNotification GCTriggered(int generation)
Parameters
Type Name Description
int generation

The expected generation.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentOutOfRangeException

generation is less than 0 or greater than MaxGeneration.

| Edit this page View Source

HeapCompaction()

Creates a filter that allows to detect heap compaction.

Declaration
public static GCNotification HeapCompaction()
Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

HeapFragmentation(double)

Creates a filter that allows to detect managed heap fragmentation threshold.

Declaration
public static GCNotification HeapFragmentation(double threshold)
Parameters
Type Name Description
double threshold

The memory threshold. The memory threshold; must be in range (0, 1].

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentOutOfRangeException

threshold is invalid.

| Edit this page View Source

MemoryThreshold(double)

Creates a filter that allows to detect managed heap occupation.

Declaration
public static GCNotification MemoryThreshold(double threshold)
Parameters
Type Name Description
double threshold

The memory threshold. The memory threshold; must be in range (0, 1].

Returns
Type Description
GCNotification

A new filter.

Remarks

This filter allows to detect a specific ratio between MemoryLoadBytes and HighMemoryLoadThresholdBytes.

Exceptions
Type Condition
ArgumentOutOfRangeException

threshold is invalid.

| Edit this page View Source

Negate()

Negates this filter.

Declaration
public virtual GCNotification Negate()
Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

Or(GCNotification)

Combines two filters using logical OR.

Declaration
public virtual GCNotification Or(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

| Edit this page View Source

Register<T>(Action<T, GCMemoryInfo>, T, bool)

Registers a callback to be executed asynchronously on approach of GC notification.

Declaration
public GCNotification.Registration Register<T>(Action<T, GCMemoryInfo> callback, T state, bool captureContext = false)
Parameters
Type Name Description
Action<T, GCMemoryInfo> callback

The callback to be executed asynchronously.

T state

The object to be passed to the callback.

bool captureContext

true to execute the callback within the captured synchronization context; otherwise, false.

Returns
Type Description
GCNotification.Registration

The object that can be used to cancel the registration.

Type Parameters
Name Description
T

The type of the state to be passed to the callback.

Remarks

The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
ArgumentNullException

callback is null.

| Edit this page View Source

WaitAsync(CancellationToken)

Waits for GC notification asynchronously.

Declaration
public Task<GCMemoryInfo> WaitAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the notification.

Returns
Type Description
Task<GCMemoryInfo>

The information about last occurred GC.

Remarks

The result of this method must be awaited. The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

WaitAsync(TimeSpan, CancellationToken)

Waits for GC notification asynchronously.

Declaration
public Task<GCMemoryInfo> WaitAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
TimeSpan timeout

The time to wait for the notification.

CancellationToken token

The token that can be used to cancel the notification.

Returns
Type Description
Task<GCMemoryInfo>

The information about last occurred GC.

Remarks

The result of this method must be awaited. The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

TimeoutException

The notification did not arrive in timely manner.

Operators

| Edit this page View Source

operator &(GCNotification, GCNotification)

Combines two filters using logical AND.

Declaration
public static GCNotification operator &(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

operator |(GCNotification, GCNotification)

Combines two filters using logical OR.

Declaration
public static GCNotification operator |(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

operator ^(GCNotification, GCNotification)

Combines two filters using logical XOR.

Declaration
public static GCNotification operator ^(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

| Edit this page View Source

operator !(GCNotification)

Negates the filter.

Declaration
public static GCNotification operator !(GCNotification filter)
Parameters
Type Name Description
GCNotification filter

The filter to negate.

Returns
Type Description
GCNotification

A new filter.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾