Accidentally found, Microsoft.IO.RecyclableMemoryStream is a smart implementation of MemoryStream.

It use small buffers (128kb by default) managed by a shared RecyclableMemoryStreamManager. This prevents allocation of large buffer in streaming mode and promote reuse.

A second pool of large buffer (multiples of 1 Mb) is only used in case of GetBuffer usage (where a byte[] must be returned).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s