From 49bc2676a7a7c08db45932ce4bfcd2e18c228a83 Mon Sep 17 00:00:00 2001
From: netty2019 <47128297+netty2019@users.noreply.github.com>
Date: Thu, 15 Aug 2024 08:35:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7Microsoft.IO.RecyclableMemory?=
 =?UTF-8?q?Stream=20=E5=88=B0=203.0.1=20=E8=A7=A3=E5=86=B3=E8=B7=9FNPOI?=
 =?UTF-8?q?=E5=86=B2=E7=AA=81=E7=AD=89=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/EPPlus/EPPlus/Magicodes.IE.EPPlus.csproj  |  2 +-
 .../EPPlus/Utils/RecyclableMemoryStream.cs    | 27 ++++++++++---------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/EPPlus/EPPlus/Magicodes.IE.EPPlus.csproj b/src/EPPlus/EPPlus/Magicodes.IE.EPPlus.csproj
index 00f4f79a..82337e81 100644
--- a/src/EPPlus/EPPlus/Magicodes.IE.EPPlus.csproj
+++ b/src/EPPlus/EPPlus/Magicodes.IE.EPPlus.csproj
@@ -53,7 +53,7 @@
 		<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
 	</ItemGroup>
 	<ItemGroup>
-		<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.1.1" />
+		<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
 		<PackageReference Include="SkiaSharp" Version="2.88.6" />
 	</ItemGroup>
 
diff --git a/src/EPPlus/EPPlus/Utils/RecyclableMemoryStream.cs b/src/EPPlus/EPPlus/Utils/RecyclableMemoryStream.cs
index 5648b291..56abc822 100644
--- a/src/EPPlus/EPPlus/Utils/RecyclableMemoryStream.cs
+++ b/src/EPPlus/EPPlus/Utils/RecyclableMemoryStream.cs
@@ -6,18 +6,21 @@ namespace OfficeOpenXml.Utils
 {
     public static class RecyclableMemoryStream
     {
-        private static readonly Lazy<RecyclableMemoryStreamManager> recyclableMemoryStreamManager = new Lazy<RecyclableMemoryStreamManager>();
-        private static RecyclableMemoryStreamManager RecyclableMemoryStreamManager
-        {
-            get
-            {
-                var recyclableMemoryStream = recyclableMemoryStreamManager.Value;
-                recyclableMemoryStream.MaximumFreeSmallPoolBytes = 64 * 1024 * 1024;
-                recyclableMemoryStream.MaximumFreeLargePoolBytes = 64 * 1024 * 32;
-                recyclableMemoryStream.AggressiveBufferReturn = true;
-                return recyclableMemoryStream;
-            }
-        }
+       private static readonly Lazy<RecyclableMemoryStreamManager> recyclableMemoryStreamManager = new Lazy<RecyclableMemoryStreamManager>(() =>
+       {
+           var option = new RecyclableMemoryStreamManager.Options();
+		   option.MaximumSmallPoolFreeBytes = 64 * 1024 * 1024;
+           option.MaximumLargePoolFreeBytes = 64 * 1024 * 32;
+           option.AggressiveBufferReturn = true;
+		   return new RecyclableMemoryStreamManager(option);
+       });
+       private static RecyclableMemoryStreamManager RecyclableMemoryStreamManager
+       {
+           get
+           {
+               return recyclableMemoryStreamManager.Value;
+           }
+       }
         private const string TagSource = "Magicodes.EPPlus";
 
         internal static MemoryStream GetStream()