From d964b638f1ad47a729ab2e6cf4d6822f76ea3e4f Mon Sep 17 00:00:00 2001 From: Christopher Moore Date: Mon, 24 Jan 2022 12:53:54 +0000 Subject: [PATCH] Reduce buffer size used in XmlReader when using Async mode (#63459) The current choice of AsyncBufferSize resulted in the character buffer in the XmlTextReader being allocated on the Large Object Heap (LOH) Fixes https://github.com/dotnet/runtime/issues/61459 --- .../System.Private.Xml/src/System/Xml/Core/XmlReader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs index c6a6c1ce3e32f..599ff04f757fd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs @@ -81,7 +81,9 @@ public abstract partial class XmlReader : IDisposable internal const int BiggerBufferSize = 8192; internal const int MaxStreamLengthForDefaultBufferSize = 64 * 1024; // 64kB - internal const int AsyncBufferSize = 64 * 1024; //64KB + // Chosen to be small enough that the character buffer in XmlTextReader when using Async = true + // is not allocated on the Large Object Heap (LOH) + internal const int AsyncBufferSize = 32 * 1024; // Settings public virtual XmlReaderSettings? Settings => null;