Dropping static byte[] allocations in .NET Framework with ReadOnlySpan<T>
Static byte[] fields are common in older .NET Framework code, but they allocate memory at startup and stay for the lifetime of the process. This post shows how ReadOnlySpan and Span can replace those arrays, even on .NET Framework, avoiding the allocation entirely. The author also walks through the generated IL and points out the potential risks of this technique.