AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

SearchIndexer..::..Dispose Method

Hides SearchIndexPluginBase.Dispose() to release the indexer's browser, parser, search-domain and configuration resources. Reached only through an IDisposable reference or a reference typed as SearchIndexer.

Namespace:  AdvantageCSP.Keyoti.SiteIndexer
Assembly:  AdvantageCSP.Keyoti.SiteIndexer (in AdvantageCSP.Keyoti.SiteIndexer.dll)

Syntax


public void Dispose()

Remarks


Do not copy this shape. The host holds the plug-in in a field typed SearchIndexPluginBase and calls Dispose() on it; that method is not virtual, so the call binds statically to the base and this body never executes. The practical consequence is that ExtendedParserProvider — and with it the browser session it owns — is never released by the host's teardown.

The extension point that does get reached is Dispose(bool): the base's public Dispose() calls it, and it is virtual. Override that instead, and always chain to base.Dispose(disposing) — the base implementation is what unsubscribes the dispatcher handlers. Because the host constructs one plug-in instance per domain in a loop over the whole run, a missed unsubscribe leaves the dispatcher holding every previous domain's plug-in, browser session and link sets alive for the lifetime of the process.

Examples


The correct disposal override for a custom indexer:
C#
protected override void Dispose(bool disposing)
{
    if (disposing)
    {
        try { if (_parserProvider != null) _parserProvider.Dispose(); }
        catch { /* teardown must not throw */ }
        _parserProvider = null;
    }
    base.Dispose(disposing);   // unsubscribes the dispatcher handlers
}