🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
RecyclableMemoryStream
This page was created by Hans.karlsen on 2019-10-14. Last edited by Wikiadmin on 2026-07-29.

You can resolve missing Microsoft.IO.RecyclableMemoryStream or System.Buffers errors by adding the required NuGet package dependencies to the project that runs your MDriven-related code.

When to use this

Add these dependencies when your application reports that it cannot find either of these assemblies:

  • Microsoft.IO.RecyclableMemoryStream
  • System.Buffers

These assemblies are used to reduce memory pressure. In particular, System.Buffers provides ArrayPool<T>, which lets code rent and return arrays instead of repeatedly allocating new arrays.

Add the required NuGet packages

  1. Open the project that produces or hosts the application where the missing-assembly error occurs.
  2. Add the NuGet package named Microsoft.IO.RecyclableMemoryStream.
  3. Add the NuGet package named System.Buffers.
  4. Restore the project's NuGet packages.
  5. Rebuild the project.
  6. Deploy the rebuilt application and verify that the missing-assembly error no longer occurs.

Add both packages when the error identifies either dependency, because the supplied implementation uses both assemblies.

How array pooling reduces allocations

An array pool is a shared collection of reusable arrays. Instead of allocating a new character array for every operation, code can rent an array from the shared pool.

For example, the following declaration uses the shared character-array pool:

private static ArrayPool<char> _pool = ArrayPool<char>.Shared;

Code can then rent an array when it needs temporary character storage:

char[] buffer = _pool.Rent(1024);

The purpose is to minimize memory pressure by reusing arrays. Ensure that code using a rented array follows the applicable pooling lifecycle, including returning the array when it is no longer needed.

Troubleshooting

Symptom Action
Error states that Microsoft.IO.RecyclableMemoryStream is missing. Add the Microsoft.IO.RecyclableMemoryStream NuGet package, restore packages, rebuild, and redeploy.
Error states that System.Buffers is missing. Add the System.Buffers NuGet package, restore packages, rebuild, and redeploy.
The error remains after adding packages. Confirm that you added the packages to the project that is deployed and that the rebuilt output is the version being run.

See also