Improve allocation with System.Buffers
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
I mainly looked through windowbase and there are various array allocations to read stream or similar. Other small arrays are so small that they could be stackallocated as they are constant length. For a perfect example check CFStream. These allocations could be removed with System.Buffers which would not have a detrimental impact on anything as far as i can tell.
I created a branch with the possible conversions in the WindowBase project. The improvements remove several immediate LOH allocations which stick around for a long time, in some instances I decided to leave the byte array allocation as the direct usage of these arrays required zeroed arrays. We could of course clear them after getting them from the ArrayPool, but then we would have to consider the tradeoff between allocation(cheap&fast) vs pool obtaining(cheap&fast) and zeroing the array (more expensive than allocation)
Contributor guide
Assessment
This issue has not been assessed yet.