3 ms·
> vast majority of extant .NET APIs encourage or require allocating memory dynamically A lot of APIs in modern .NET already supports spans. They can be backed
by Const-me 6y ago
> vast majority of extant .NET APIs encourage or require allocating memory dynamically
A lot of APIs in modern .NET already supports spans. They can be backed by anything, not just GC-managed memory.
For that project, some of these spans are backed by the memory mapped by V4L2 or ALSA API calls. Others are backed by unmanaged buffers allocated on startup with Marshal.AllocHGlobal. For small temporary stuff I use stackalloc, e.g. both mp4 and mkv use tons of variable-length encoded integers.
> the minute someone _else_ contributes code, you run the risk of allocating again.
Good point. On the other hand, someone else contributing code can introduce any bugs at all, not just GC-related performance issues.
> As much as I love C#, _this isn't its niche_.
A while ago some people were saying the same about C, and were instead coding assembly :-)