NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet, #137 most downloaded on NuGet
A pooled MemoryStream allocator to decrease GC load and improve performance on highly scalable systems.
Latest stable
4.0.1
Last release 25 days ago
28 Oct 2026
Ships unpredictably
gaps range from 2 weeks to 2.1 years
Nearly every release is documented
notes for 25 of 25 stable releases
2 versions withdrawn
withdrawn after publishing
127 years old
29 releases · first in 1900
Drag across the ruler to compare, or tap a release to open it.
Switch MemoryStreamDoubleDispose event level from Critical to Verbose PR #406
Breaking Changes
MemoryStreamDoubleDispose event level from Critical to Verbose PR #406Bug Fixes
New Features
EventSourcePrimtives for logging.Other Changes
GetBuffer method pertaining to the .NET max array length PR #370Breaking Changes
MemoryStreamDoubleDispose event level from Critical to Verbose PR #406Bug Fixes
New Features
EventSourcePrimtiives for loggingOther Changes
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Nothing published for this version
Nothing published for this version
Fix infinite loop bug when calling (Try)GetBuffer on a stream longer than 1 GB when using the UseExponentialLargeBuffer option. (Issue #344 )
Bug Fix
Fix infinite loop bug when calling (Try)GetBuffer on a stream longer than 1 GB when using the UseExponentialLargeBuffer option. (Issue #344)
Removed int -based constructor and GetStream overloads where long -based methods exist.
Breaking Changes
int-based constructor and GetStream overloads where long-based methods exist.[Obsolete]:
StreamDisposedEventArgs.ctor(Guid, string, string, string)RecyclableMemoryStreamManager.GetStream(Guid, string, Memory<byte>)RecyclableMemoryStreamManager.GetStream(Memory<byte>)RecyclableMemoryStreamManager.GetStream(string, Memory<byte>)<Nullable>enabled</Nullable> to the project file.RecyclableMemoryStreamManager.GetStream now return type RecyclableMemoryStream instead of MemoryStream.RecyclableMemoryStreamManager to the new RecyclableMemoryStreamManager.Options class. Removed many of the constructors as a result. This class will facilitate easier dependency injection through use of the Options pattern, for those who need it.MaximumLargePoolFreeBytes)New Features
RecyclableMemoryStreamManager: ZeroOutBuffer, which will cause all buffers to be cleared on allocation and when returning to the pool. Off by default.Other Changes
Calculating blocks and offsets was made more efficient by using Math.DivRem .
Optimizations:
Math.DivRem.CopyTo was overridden to avoid using the slower default implementation.Stream lifetime (creation through dispose) is now tracked and reported through the MemoryStreamDispose EventSource event, as well as through the Strea
New Feature:
MemoryStreamDispose EventSource event, as well as through the StreamDisposed .NET event.Changes:
MemoryStreamDiscardBuffer event.Bug Fixes:
NullReferenceException in some low-memory scenarios.Internal:
Co-authored-by: Ben Watson bewatson@microsoft.com
Co-authored-by: Ben Watson bewatson@microsoft.com
There are now overloads that take a type long parameter for requestedSize.
API change:
long parameter for requestedSize.Bug Fix:
ToString will no longer throw an exception if the stream is disposed.Additional framework targets, better .Net Core support, simplified build.
Additional framework targets, better .Net Core support, simplified build.
API changes:
GetStream that takes a ReadOnlySpan<byte>. This supercedes the versions of GetStream that take Memory<byte>, which were marked as [Obsolete].Bug Fixes:
GetReadOnlySequence() throws ArgumentOutOfRangeExceptionPerformance Improvements:
EnsureCapacity will always run, potentially resizing the list anyway.GC.AllocateUninitializedArray in an additional spot, for better performance in .NET 5+.Documentation:
API changes
GetStream that takes a ReadOnlySpan<byte>. This supersedes the versions of GetStream that take Memory<byte>, which were marked as [Obsolete].Bug Fixes
GetReadOnlySequence() throws ArgumentOutOfRangeExceptionPerformance Improvements
EnsureCapacity will always run, potentially resizing the list anyway.GC.AllocateUninitializedArray in an additional spot, for better performance in .NET 5+.Documentation
Additional framework targets, better .Net Core support, simplified build.
Additional framework targets, better .Net Core support, simplified build.
Fixed another integer overrun math bug related to the new 64-bit data sizes that handle longer streams. The tests have also been updated to check for more issues like this.
** Bug Fixes**
Fixed an integer overflow bug when buffer sizes are near Int32.MaximumValue
Changes:
Int32.MaximumValueBug Fixes
[SecurityRules(SecurityRuyleSet.Level1)] to assembly to allow more relaxed inheritance security rules.Fixed a bug introduced in 2.1.0 related to security inheritance rules
Added RecyclableMemoryStreamManager constructor overloads that take parameters for specifying the maximum free pool sizes. Updated IntelliSense docume
RecyclableMemoryStreamManager constructor overloads that take parameters for specifying the maximum free pool sizes. Updated IntelliSense documentation to make clear that these values need to be explciitly set to avoid unbounded pool growth.GC.AllocateUninitializedArray in .NET 5.Span-related APIs via a dependency on System.Memory.Removed 2 GB stream limit. Extremely large streams can be created by chaining together blocks. Attempts to convert a stream into a contiguous buffer l
Major new release!
Breaking Changes
GetBuffer now throws OutOfMemoryException instead of InvalidOperationException if the needed size is too large for a contiguous array.Other Changes
Interlocked methods when checking whether the stream is disposed. This should improve performance. (Concurrent use of streams has never been supported.)RecyclableMemoryStream now implements IBufferWriter<byte>WriteTo that allow you write the contents of the stream directly to another byte[] buffer.Development-only Changes
Fixed a bug in CopyToAsync where it wasn't updating the current position, just like a Read would. This was different behavior than in the base class,
CopyToAsync where it wasn't updating the current position, just like a Read would. This was different behavior than in the base class, MemoryStream.Added netstandard2.0 target. There was an issue calling GetBuffer from a netstandard2.0 project, which would resolve to the netstandard1.4 target of R
Some important updates:
GetBuffer from a netstandard2.0 project, which would resolve to the netstandard1.4 target of RMS. netstandard1.4 doesn't support overriding GetBuffer, so you could hit UnauthorizedAccessException.CopyToAsync. It was copying the entire stream, but the expected behavior based on System.IO.MemoryStream is to copy from the current position.CopyToAsync (Thank you @paulomorgado)Override CopyToAsync to save some allocations.
Minor updates:
CopyToAsync to save some allocations.AllowPartiallyTrustedCallers attribute to assembly (Thank you @LIFEfreedom)These changes are thanks to @ninedan
These changes are thanks to @ninedan
Performance Improvements
WriteByte has been significantly optimized to be faster.CheckDisposed, which is called in many code paths, has similarly been optimized.void WriteTo(Stream stream, int offset, int count) -- Allows you to write a portion of the current stream to a destination stream without first having
New API:
void WriteTo(Stream stream, int offset, int count) -- Allows you to write a portion of the current stream to a destination stream without first having to call GetBuffer.Added RecyclableMemoryStreamManager.ThrowExceptionOnToArray. Causes a NotSupportedException to be thrown if RecyclableMemoryStream.ToArray is called.
New APIs:
RecyclableMemoryStreamManager.ThrowExceptionOnToArray. Causes a NotSupportedException to be thrown if RecyclableMemoryStream.ToArray is called. Default is false.RecyclableMemoryStreamManager.GetStream that accept Memory<byte> arguments.Functionality
RecyclableMemoryStreamManager.ThrowExceptionOnToArray. Causes a NotSupportedException to be thrown if RecyclableMemoryStream.ToArray is called. Default is false.RecyclableMemoryStreamManager.GetStream that accept Memory<byte> arguments.Meta
Due to a build pipeline issue, the previous release unfortunately had Debug binaries instead of Release. That has been remedied in 1.3.2. No code chan
Due to a build pipeline issue, the previous release unfortunately had Debug binaries instead of Release. That has been remedied in 1.3.2. No code changes.
Bug Fixes
Performance
Read, SafeRead, and Write that accept Span arguments (.NET Core and .NET Standard targets only)Functionality
TryGetBuffer, introduced in .NET Framework 4.6.Meta
Nothing published for this version
A long-awaited update, this release adds a number of new features, fixes bugs, and is more interoperable with .NET Core.
A long-awaited update, this release adds a number of new features, fixes bugs, and is more interoperable with .NET Core.
NuGet: Microsoft.IO.RecyclableMemoryStream
Bug Fixes
Performance
Functionality
Meta
Multi-framework targeting adds support for .NET Standard 1.4.
Changes:
Additional fix for allocating streams up to int.MaxValue length.
Changes:
Bugs fixed when allocating very large streams.
Changes:
Binaries on nuget.org are now signed through Microsoft.
Changes:
- Initial release.
One column per quarter.