Removing byte[] allocations in .NET Framework using ReadOnlySpan The article explains how developers can reduce byte array allocations in .NET Framework by using `ReadOnlySpan` instead of traditional byte arrays, even on older runtimes. It describes how `ReadOnlySpan` provides a memory-efficient "view" over existing data without creating copies, and highlights that this optimization can be applied to static data fields in C# 8.0 and later. The technique allows for reduced garbage collection pressure and improved performance by avoiding heap allocations for read-only data. In this post I describe a simple way to remove some byte allocations, no matter which version of .NET you're targeting, including .NET Framework. This will likely already be familiar to you if you write performance sensitive code with modern .NET, but I recently realised that this can be applied to older runtimes as well, like .NET Framework. This post looks at the changes to your C code to reduce the allocations, how the compiler implements the change behind the scenes, and some of the caveats and sharp edges to watch out for. Span