Skip to content

Commit 71e191b

Browse files
committed
Fix memory leak from not releasing the memory mapped file pointer
1 parent 201e080 commit 71e191b

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/NerdBank.GitVersioning/ManagedGit/GitPackIndexMappedReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public override (long? Offset, GitObjectId? ObjectId) GetOffset(Span<byte> objec
134134
/// <inheritdoc/>
135135
public override void Dispose()
136136
{
137+
this.accessor?.SafeMemoryMappedViewHandle.ReleasePointer();
137138
this.accessor?.Dispose();
138139
this.accessor = null;
139140
this.file.Dispose();
@@ -146,6 +147,7 @@ private unsafe ReadOnlySpan<byte> GetSpan(ulong offset, int length)
146147
// If the request is for a window that we have not currently mapped, throw away what we have.
147148
if (this.accessor is not null && (this.accessorOffset > offset || this.accessorOffset + this.accessorSize < offset + (ulong)length))
148149
{
150+
this.accessor.SafeMemoryMappedViewHandle.ReleasePointer();
149151
this.accessor.Dispose();
150152
this.accessor = null;
151153
}

0 commit comments

Comments
 (0)