Skip to content

Commit c31ea8b

Browse files
committed
Fixed potential internal race condition with group buffer memory management
- Added a line to capture `groupCount` from `generationArray.Groups.Length` in `MemorySegmentedBufferPool.cs` to improve buffer management. - Updated the version number in `Directory.Build.props` to 2.0.1. - Enhanced release notes in `KZDev.PerfUtils.csproj` to include a bug fix for a potential internal race condition.
1 parent 73871d6 commit c31ea8b

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

Source/Src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PropertyGroup Label="SourceGlobals">
1010
<Configurations>Debug;Release;Profile;Package</Configurations>
1111
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
12-
<Version>2.0.0</Version>
12+
<Version>2.0.1</Version>
1313
<Authors>Kevin Zehrer</Authors>
1414
<Copyright>Copyright © 2024-2025 Kevin Zehrer. All rights reserved.</Copyright>
1515
<Product>KZDev Performance Utilities</Product>

Source/Src/KZDev.PerfUtils/KZDev.PerfUtils.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageIcon>images\icon.png</PackageIcon>
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1414
<PackageDescription>Performance utilities for .NET projects, including the MemoryStreamSlim, StringBuilderCache, InterlockedOps, and Compression classes.</PackageDescription>
15-
<PackageReleaseNotes>.NET 9 Support, MemoryStreamSlim Int64 Capacity Support, Added compression stream helper classes (version 2.0.0).</PackageReleaseNotes>
15+
<PackageReleaseNotes>.NET 9 Support, MemoryStreamSlim Int64 Capacity Support, Added compression stream helper classes (version 2.0.0). Bug fix for potential internal race condition (version 2.0.1).</PackageReleaseNotes>
1616
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1717
<RepositoryUrl>https://github.com/kzdev-net/kzdev.perfutils</RepositoryUrl>
1818
</PropertyGroup>

Source/Src/KZDev.PerfUtils/Memory/Internals/MemorySegmentedBufferPool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal class MemorySegmentedBufferPool : IDisposable
2121
/// </summary>
2222
private const int TrimTimerIntervalMs =
2323
#if DEBUG
24-
20_000;
24+
20_000;
2525
#else
2626
600_000;
2727
#endif
@@ -398,6 +398,7 @@ private SegmentBuffer RentFromGeneration (long requestedBufferSize,
398398
// Someone else already expanded the array group, so we will just try again with that
399399
// generation.
400400
generationArray = currentGenerationArray;
401+
groupCount = generationArray.Groups.Length;
401402
}
402403
}
403404
//--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)