Pool readers and streams with Json.NET This code is built on Json.NET and gets called hundreds of times per second. My data starts in an ArraySegment&lt;byte&gt;. I wrap that in a MemoryStream and pass it in to the code. It's generally small data: hundreds of bytes, not thousands. It just doesn't seem right that I have to construct multiple streams and readers for every single deserialization call. How do I optimize this? How do I reuse those two readers?

public object Deserialize(Stream stream, Type type)
{
    using (var utfReader = new StreamReader(stream, Encoding.UTF8, true, 2048, true))
    using (var reader = new JsonTextReader(utfReader) { CloseInput = false })
        return _serializer.Deserialize(reader, type);
}

public T Deserialize&lt;T&gt;(Stream stream)
{
    return (T)Deserialize(stream, typeof(T));
}
You could create your own TextReader that allows you to change the underlying Stream, or even directly reads from the ArraySegment&lt;byte&gt;.

But hundreds of times per second is not that often, are you sure worrying about allocations here is worth it? And if it is, I would first look at the 2 kB of buffer your StreamReader allocates every time it's created, rather than the few tens of bytes for the StreamReader and JsonTextReader objects.