Issue 488 · Week of May 11, 2026
Feed Jobs Search Platform About Donate
← Back to feed / //dotnet

Dropping static byte[] allocations in .NET Framework with ReadOnlySpan<T>

Read full article Discuss
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.