microsoft / Microsoft.IO.RecyclableMemoryStream

A library to provide pooling for .NET MemoryStream objects to improve application performance.
MIT License
1.99k stars 206 forks source link

Injecting into AspNetCore, gRPC, Json? #359

Open AnthonyLloyd opened 1 week ago

AnthonyLloyd commented 1 week ago

Is there any general way to inject the use of RecycleableMemoryStream in AspNetCore or gRPC or even JsonSerializer? I've had a look at AspNetCore and I think it's specifically possible if say you skip the content negotiation but I was wondering if we can use it more widely in an app.

benmwatson commented 1 week ago

Probably a better question for those frameworks than this project.

Technically, if you can inject usage of any MemoryStream-equivalent, then you could use RMS. However, to get the benefits of RMS requires a bit more care, so it might be more difficult to do a blanket override of default behavior. So much depends on specific usage.