fix: Fixes massive capacity bug with pooled ref queue/list (#1865)
This commit is contained in:
parent
96de1fdaa1
commit
21836cf62f
4 changed files with 20 additions and 30 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue