|
|
|
@ -6,11 +6,13 @@ using System; |
|
|
|
using System.Buffers; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using SixLabors.Tests; |
|
|
|
using SixLabors.ImageSharp.Tests; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace SixLabors.Memory.Tests |
|
|
|
{ |
|
|
|
// TODO: Re-enable memory-intensive tests with arcade RemoteExecutor:
|
|
|
|
// https://github.com/dotnet/runtime/blob/master/docs/project/writing-tests.md#remoteexecutor
|
|
|
|
public class ArrayPoolMemoryAllocatorTests |
|
|
|
{ |
|
|
|
private const int MaxPooledBufferSizeInBytes = 2048; |
|
|
|
@ -79,7 +81,7 @@ namespace SixLabors.Memory.Tests |
|
|
|
Assert.True(this.CheckIsRentingPooledBuffer<byte>(size)); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[Theory(Skip = "Should be executed from a separate process.")] |
|
|
|
[InlineData(128 * 1024 * 1024)] |
|
|
|
[InlineData(MaxPooledBufferSizeInBytes + 1)] |
|
|
|
public void LargeBuffersAreNotPooled_OfByte(int size) |
|
|
|
@ -101,7 +103,7 @@ namespace SixLabors.Memory.Tests |
|
|
|
Assert.True(this.CheckIsRentingPooledBuffer<LargeStruct>(count)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
[Fact(Skip = "Should be executed from a separate process.")] |
|
|
|
public unsafe void LaregeBuffersAreNotPooled_OfBigValueType() |
|
|
|
{ |
|
|
|
if (!TestEnvironment.Is64BitProcess) |
|
|
|
@ -160,7 +162,8 @@ namespace SixLabors.Memory.Tests |
|
|
|
buffer.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
|
|
[Fact(Skip = "Should be executed from a separate process.")] |
|
|
|
public void AllocationOverLargeArrayThreshold_UsesDifferentPool() |
|
|
|
{ |
|
|
|
if (!TestEnvironment.Is64BitProcess) |
|
|
|
@ -180,7 +183,7 @@ namespace SixLabors.Memory.Tests |
|
|
|
Assert.False(Unsafe.AreSame(ref ptr2Small, ref large.GetReference())); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
[Fact(Skip = "Should be executed from a separate process.")] |
|
|
|
public void CreateWithAggressivePooling() |
|
|
|
{ |
|
|
|
if (!TestEnvironment.Is64BitProcess) |
|
|
|
@ -194,7 +197,7 @@ namespace SixLabors.Memory.Tests |
|
|
|
Assert.True(this.CheckIsRentingPooledBuffer<Rgba32>(4096 * 4096)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
[Fact(Skip = "Should be executed from a separate process.")] |
|
|
|
public void CreateDefault() |
|
|
|
{ |
|
|
|
if (!TestEnvironment.Is64BitProcess) |
|
|
|
|