Skip to content

Commit

Permalink
RavenDB-23704 - reset the _allocationBlockSize to its initial value w…
Browse files Browse the repository at this point in the history
…hen doing a Reset
  • Loading branch information
grisha-kotler committed Feb 18, 2025
1 parent 9d8ba91 commit 7a7e391
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Sparrow.Server/ByteString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ public override string ToString()
/// This list keeps all the segments already instantiated in order to release them after context finalization.
/// </summary>
private readonly List<SegmentInformation> _wholeSegments;
private readonly int _initialAllocationBlockSize;
private int _allocationBlockSize;

internal long _totalAllocated, _currentlyAllocated;
Expand Down Expand Up @@ -778,6 +779,7 @@ public ByteStringContext(SharedMultipleUseFlag lowMemoryFlag, int allocationBloc
throw new ArgumentException($"It is not a good idea to allocate chunks of less than the {nameof(ByteStringContext.MinBlockSizeInBytes)} value of {ByteStringContext.MinBlockSizeInBytes}");

_lowMemoryFlag = lowMemoryFlag;
_initialAllocationBlockSize = allocationBlockSize;
_allocationBlockSize = allocationBlockSize;

_wholeSegments = new List<SegmentInformation>();
Expand Down Expand Up @@ -823,6 +825,7 @@ public void Reset()
stack?.Clear();
}
_internalReadyToUseMemorySegments.Clear();// memory here will be released from _wholeSegments
_allocationBlockSize = _initialAllocationBlockSize;

_externalStringPool.Clear();
_externalFastPoolCount = 0;
Expand Down

0 comments on commit 7a7e391

Please sign in to comment.