Skip to content

Commit b3e1400

Browse files
authored
Merge pull request #65 from grisha-kotler/RavenDB-21305-6.0
RavenDB-21305 - add a finalizer to TermInfosReader
2 parents 621acd3 + 968cf38 commit b3e1400

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>3.0.60009</Version>
4-
<FileVersion>3.0.60009</FileVersion>
3+
<Version>3.0.60010</Version>
4+
<FileVersion>3.0.60010</FileVersion>
55
<LangVersion>latest</LangVersion>
66
<DebugType>embedded</DebugType>
77

src/Lucene.Net/Index/TermInfosReader.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ public int MaxSkipLevels
143143

144144
public void Dispose()
145145
{
146-
if (isDisposed) return;
146+
if (isDisposed)
147+
return;
148+
149+
GC.SuppressFinalize(this);
147150

148151
// Move to protected method if class becomes unsealed
149152
if (origEnum != null)
@@ -156,6 +159,18 @@ public void Dispose()
156159

157160
isDisposed = true;
158161
}
162+
163+
~TermInfosReader()
164+
{
165+
// each TermInfosReader holds a cache (ArrayHolder) which is created upon creation of the TermInfosReader instance.
166+
// in the past we created a new ArrayHolder when creating a new TermInfosReader instance.
167+
// if it wasn't disposed, nothing happened since we have a finalizer for the ArrayHolder.
168+
// we changed the implementation and now this cache is shared between different instances of TermInfosReader.
169+
// when TermInfosReader isn't disposed we are still holding a reference to the ArrayHolder.
170+
171+
// releasing the reference for the cached ArrayHolder will match the previous behaviour.
172+
_termsIndexCache?.ReleaseRef();
173+
}
159174

160175
/// <summary>Returns the number of term/value pairs in the set. </summary>
161176
internal long Size()

0 commit comments

Comments
 (0)