From 6ed6cc0f60885e6fac3d9fb1ce3a1ae5b9a80b89 Mon Sep 17 00:00:00 2001 From: Christopher Moore Date: Thu, 6 Jan 2022 17:08:29 +0000 Subject: [PATCH] Reduce buffer size used in XmlReader when using Async mode 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 c6a6c1ce3e32f4..599ff04f757fd1 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;