CondensedCollectionTInternedValueReclaimable Event |
[This is preliminary documentation and is subject to change.]
Namespace: Condensed
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.
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; }