# Removing byte\[\] allocations in .NET Framework using ReadOnlySpan

DevFeed: [Removing byte\[\] allocations in .NET Framework using ReadOnlySpan](<https://devfeed.tech/articles/removing-byte-allocations-in-net-framework-using-readonlyspan-51484.md>)

Original publisher: [Read original article](<https://andrewlock.net/removingbyte-array-allocations-in-dotnet-framework-using-readonlyspan-t/>)

Author: Andrew Lock

Published: 2026-04-21T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [.NET Framework](<https://devfeed.tech/topics/net-framework.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Code](<https://devfeed.tech/topics/code.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-performance](<https://devfeed.tech/tags/c-sharp-performance.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [memory](<https://devfeed.tech/tags/memory.md>), [net](<https://devfeed.tech/tags/net.md>), [net-framework](<https://devfeed.tech/tags/net-framework.md>), [optimizations](<https://devfeed.tech/tags/optimizations.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

This post explains how to reduce byte-array and other memory allocations in C# applications targeting .NET, including .NET Framework. It covers using Span and ReadOnlySpan, compiler-generated optimizations, changes to the generated IL, and relevant caveats.

## Source excerpt

In this post I describe how to remove static byte[] allocations, even on .NET Framework, by using Span, look at the associated IL, and discuss the risks