fix: Fixes massive capacity bug with pooled ref queue/list (#1865)

This commit is contained in:
Kamron Batman 2024-07-07 16:18:56 -07:00 • committed by GitHub
parent 96de1fdaa1
commit 21836cf62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 30 deletions

View file

@ -6,7 +6,6 @@ using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Server.Buffers;
namespace Server.Collections;
@ -152,14 +151,14 @@ public ref struct PooledRefList<T>
if (_items.Length > 0)
{
Clear();
Array.Clear(_items);
ArrayPool.Return(_items);
}
_items = newItems;
}
else
{
Clear();
Array.Clear(_items);
ArrayPool.Return(_items);
_items = s_emptyArray;
}

View file

@ -305,7 +305,7 @@ public ref struct PooledRefQueue<T>
if (_array.Length > 0)
{
Clear();
Array.Clear(_array);
(_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Return(_array);
}