diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5e5d2ec1fa..cbd61f49a0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 3.0.60009 - 3.0.60009 + 3.0.60010 + 3.0.60010 latest embedded diff --git a/src/Lucene.Net/Index/TermInfosReader.cs b/src/Lucene.Net/Index/TermInfosReader.cs index 5afbe96491..39069a4e8e 100644 --- a/src/Lucene.Net/Index/TermInfosReader.cs +++ b/src/Lucene.Net/Index/TermInfosReader.cs @@ -143,7 +143,10 @@ public int MaxSkipLevels public void Dispose() { - if (isDisposed) return; + if (isDisposed) + return; + + GC.SuppressFinalize(this); // Move to protected method if class becomes unsealed if (origEnum != null) @@ -156,6 +159,18 @@ public void Dispose() isDisposed = true; } + + ~TermInfosReader() + { + // each TermInfosReader holds a cache (ArrayHolder) which is created upon creation of the TermInfosReader instance. + // in the past we created a new ArrayHolder when creating a new TermInfosReader instance. + // if it wasn't disposed, nothing happened since we have a finalizer for the ArrayHolder. + // we changed the implementation and now this cache is shared between different instances of TermInfosReader. + // when TermInfosReader isn't disposed we are still holding a reference to the ArrayHolder. + + // releasing the reference for the cached ArrayHolder will match the previous behaviour. + _termsIndexCache?.ReleaseRef(); + } /// Returns the number of term/value pairs in the set. internal long Size()