Class GCNotification
Provides a way to receive notifications from Garbage Collector asynchronously.
Inherited Members
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public abstract class GCNotification
Methods
| Edit this page View SourceAnd(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 |
|
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 |
|
GCTriggered()
Creates a filter that triggers notification on every GC occurred.
Declaration
public static GCNotification GCTriggered()
Returns
Type | Description |
---|---|
GCNotification | A new filter. |
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 |
|
HeapCompaction()
Creates a filter that allows to detect heap compaction.
Declaration
public static GCNotification HeapCompaction()
Returns
Type | Description |
---|---|
GCNotification | A new filter. |
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 |
|
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 |
|
Negate()
Negates this filter.
Declaration
public virtual GCNotification Negate()
Returns
Type | Description |
---|---|
GCNotification | A new filter. |
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 |
|
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 |
|
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. |
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 Sourceoperator &(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. |
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. |
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. |
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. |