RenderGraph is causing many GC allocations per frame

This function is producing an exceedingly large amount of unnecessary GC allocations:

public readonly ReadOnlySpan<PassData> GraphPasses(CompilerContextData ctx)

It looks like in the case where passes are culled it decides to allocate a new list.

Why not just use

var actualPasses = new NativeArray<PassData>(numGraphPasses, 
                                             Allocator.Temp, NativeArrayOptions.UninitializedMemory);

instea of

var actualPasses = new PassData[numGraphPasses];

as that memory will cleaned up at the end of the frame anyway? Or preallocate the filtered list as it’s all internal code that’s only used in a few simple loops.

In my project this was causing 2.5kb of allocations a frame, which was tanking my editor performance with incremental GC enabled. I made a test branch of Core RP and my suggested code does solve the problem.

Still a problem on 6000.2.15f1
I thought they’ve used some clever design to overcome GC, but no, turns out it’s just like that.