> Spans and slice-like structures in are the future of safe memory operations in modern programming languages. Embrace them.
I've been using Span<T> very aggressively and it makes a massive difference in cases where you need logical views into the same physical memory. All of my code has been rewritten to operate in terms of spans instead of arrays where possible.
It can be easy to overlook ToArray() or (more likely) code that implies its use in a large codebase. Even small, occasional allocations are all it takes to move your working set out of the happy place and get the GC cranking. The difference in performance can be unreasonable in some cases.
You can even do things like:
var arena = stackalloc byte[1024];
var segment0 = arena.Slice(10);
var segment1 = arena.Slice(10, 200);
...
The above will incur no GC pressure/activity at all. Everything happens on the stack.