You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by gfoidl December 1, 2022
For each request a new MemoryStream is created, thus also the backing byte[]-buffer used by MS and if it needs to be resized another buffer with copying over the old contents, and so on.
As response header values can't be set once the body has started, any kind of temporary stream needs to be used -- as it's done now.
But instead of creating a MS every time there should be some kind of pooling, e.g. via Microsoft.IO.RecyclableMemoryStream.
Is this in general something to look into, and is it OK to rely on that package?
Otherwise there could be some inbox-solution for pooled streams based on ArrayPool, etc.
I didn't run any benchmarks so far, just saw this when reading the code.
I can create a PR if needed..
The text was updated successfully, but these errors were encountered:
Discussed in #2408
Originally posted by gfoidl December 1, 2022
For each request a
new MemoryStream
is created, thus also the backingbyte[]
-buffer used by MS and if it needs to be resized another buffer with copying over the old contents, and so on.As response header values can't be set once the body has started, any kind of temporary stream needs to be used -- as it's done now.
But instead of creating a MS every time there should be some kind of pooling, e.g. via Microsoft.IO.RecyclableMemoryStream.
Is this in general something to look into, and is it OK to rely on that package?
Otherwise there could be some inbox-solution for pooled streams based on ArrayPool, etc.
I didn't run any benchmarks so far, just saw this when reading the code.
I can create a PR if needed..
The text was updated successfully, but these errors were encountered: