How does the .NET garbage collector decide what to collect, and how would you make a hot path allocate less?
The GC segregates the heap into generations on the assumption that most objects die young, collecting gen0 often and gen2 rarely, with large objects on a separate heap that is not compacted by default. Allocating less means removing boxing and using Span<T> over pooled or stack memory.