diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs b/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs
index 9df9e794aa..b062df7118 100644
--- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs
+++ b/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Memory
{
///
/// Defines the default maximum size of pooled arrays.
- /// Currently set to a value equivalent to 16 Megapixels of an image.
+ /// Currently set to a value equivalent to 16 MegaPixels of an image.
///
public const int DefaultMaxSizeInBytes = 4096 * 4096 * 4;
@@ -22,8 +22,19 @@ namespace SixLabors.ImageSharp.Memory
/// Initializes a new instance of the class.
///
public ArrayPoolMemoryManager()
+ : this(DefaultMaxSizeInBytes)
{
- this.pool = ArrayPool.Create(DefaultMaxSizeInBytes, 50);
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ /// The maximum size of pooled arrays. Arrays over the thershold are gonna be always allocated.
+ ///
+ public ArrayPoolMemoryManager(int maxPoolSizeInBytes)
+ {
+ Guard.MustBeGreaterThan(maxPoolSizeInBytes, 0, nameof(maxPoolSizeInBytes));
+
+ this.pool = ArrayPool.Create(maxPoolSizeInBytes, 50);
}
///
diff --git a/src/ImageSharp/Memory/Buffer{T}.cs b/src/ImageSharp/Memory/Buffer{T}.cs
index d25cc232ad..07a827a67d 100644
--- a/src/ImageSharp/Memory/Buffer{T}.cs
+++ b/src/ImageSharp/Memory/Buffer{T}.cs
@@ -99,7 +99,9 @@ namespace SixLabors.ImageSharp.Memory
get
{
DebugGuard.MustBeLessThan(index, this.Length, nameof(index));
- return ref this.Array[index];
+
+ Span span = this.Span;
+ return ref span[index];
}
}