Click or drag to resize

CondensedCollectionTInternedValueReclaimable Event

[This is preliminary documentation and is subject to change.]

Event that is raised when an item in the intern pool of unique values is no longer stored in the collection.

Namespace:  Condensed
Assembly:  Condensed (in Condensed.dll) Version: 0.1.0.0 (0.1.0.0)
Syntax
public event EventHandler<InternReclaimableEventArgs> InternedValueReclaimable

Value

Type: SystemEventHandlerInternReclaimableEventArgs
Remarks

Stats provided via an event handler's InternReclaimableEventArgs are intended to be used to decide whether a cleanup should be performed. Set the Cleanup property to true to perform a cleanup after the event hander returns.

Cleanups are expensive and typically should not be performed every time the event is raised; consider cleaning up only when the InternPoolCount is significantly larger than the UniqueCount.

This event will not be fired if the collection has cutover to a non-deduplicated list.

C#
static void Main()
{
    var cc = new CondensedCollection<string>(comparer: StringComparer.Ordinal);
    cc.InternedValueReclaimable += HandleInternedValueReclaimable;   
}

static void HandleInternedValueReclaimable(object sender, InternReclaimableEventArgs e)
{
    // Perform cleanup as soon as we have 1000 unused strings in our intern pool.
    // After cleanup completes, those unused values will be eligible for garbage collection.
    if (e.ReclaimableInternsCount > 999)
        e.Cleanup = true;
}
See Also