diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs index 75328f71473c36..d804cca460c2bd 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs @@ -553,10 +553,11 @@ public static partial class JsonSerializer { Debug.Assert(listTypeInfo.IsConfigured); - ReadBufferState bufferState = new(listTypeInfo.Options.DefaultBufferSize); ReadStack readStack = default; readStack.Initialize(listTypeInfo, supportContinuation: true); JsonReaderState jsonReaderState = new(readerOptions); + // Note: The ReadBufferState ctor rents pooled buffers. + ReadBufferState bufferState = new(listTypeInfo.Options.DefaultBufferSize); try { diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs index bfe0f394d42717..3ea5e94b8ce9cb 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs @@ -26,10 +26,11 @@ public partial class JsonTypeInfo { Debug.Assert(IsConfigured); JsonSerializerOptions options = Options; - var bufferState = new ReadBufferState(options.DefaultBufferSize); ReadStack readStack = default; readStack.Initialize(this, supportContinuation: true); var jsonReaderState = new JsonReaderState(options.GetReaderOptions()); + // Note: The ReadBufferState ctor rents pooled buffers. + ReadBufferState bufferState = new(options.DefaultBufferSize); try { @@ -58,10 +59,11 @@ public partial class JsonTypeInfo { Debug.Assert(IsConfigured); JsonSerializerOptions options = Options; - var bufferState = new ReadBufferState(options.DefaultBufferSize); ReadStack readStack = default; readStack.Initialize(this, supportContinuation: true); var jsonReaderState = new JsonReaderState(options.GetReaderOptions()); + // Note: The ReadBufferState ctor rents pooled buffers. + ReadBufferState bufferState = new(options.DefaultBufferSize); try {