Skip to content

Commit 6071e44

Browse files
committed
Add ArrayPool size limit manipulations
1 parent c70292e commit 6071e44

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/Pooling/BaseArrayPoolProvider.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ internal class BaseArrayPoolProvider<T> : IArrayPoolProvider<T>
77
{
88
private readonly int maxSetCapacity;
99
private readonly int maxArrayLength;
10-
1110
private readonly T[] empty;
1211
private readonly Stack<T[]>[] pooledArrays;
1312

14-
public BaseArrayPoolProvider()
13+
public BaseArrayPoolProvider(int poolCapacity, int arrayMaxLength)
1514
{
16-
maxSetCapacity = 100;
17-
maxArrayLength = 50;
15+
maxSetCapacity = poolCapacity;
16+
maxArrayLength = arrayMaxLength;
1817
// ReSharper disable once VirtualMemberCallInConstructor
1918
empty = InstantiateArray(0);
20-
2119
pooledArrays = new Stack<T[]>[maxArrayLength];
2220

2321
for (int i = 0; i < pooledArrays.Length; i++)
@@ -26,6 +24,10 @@ public BaseArrayPoolProvider()
2624
}
2725
}
2826

27+
public BaseArrayPoolProvider() : this(100, 50)
28+
{
29+
}
30+
2931
public T[] Take() => empty;
3032

3133
public T[] Take(int length)

0 commit comments

Comments
 (0)