Skip to content

Consider using pooled buffers for HttpClient response buffering  #62845

@geoffkizer

Description

@geoffkizer

I was looking at a memory trace of HttpClient today, and noticed this. Response buffering in HttpClient uses MemoryStream under the covers to buffer the response. MemoryStream does not currently use pooled buffers (i.e. `ArrayPool'). Seems like using pooled buffers here would be a better solution and would avoid GC costs.

There's an issue for MemoryStream to use pooled buffers itself here: #22428. If this got implemented, we could simply use this. It's unclear if/when this will happen, though.

Alternatively, we could just implement our own Stream here for response buffering, instead of using MemoryStream. This may have additional advantages since we don't really need all the functionality of MemoryStream here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Net.Httpin-prThere is an active PR which will close this issue when it is mergedtenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions