File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
tests/ImageSharp.Tests/Memory/Allocators Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,30 @@ private static void AllocateSingleAndForget(UniformUnmanagedMemoryPoolMemoryAllo
398
398
}
399
399
}
400
400
401
+ [ Fact ]
402
+ public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException ( )
403
+ {
404
+ MemoryAllocator allocator = MemoryAllocator . Create ( new MemoryAllocatorOptions ( )
405
+ {
406
+ AllocationLimitMegabytes = 4
407
+ } ) ;
408
+ const int oneMb = 1 << 20 ;
409
+ allocator . Allocate < byte > ( 4 * oneMb ) . Dispose ( ) ; // Should work
410
+ Assert . Throws < InvalidMemoryOperationException > ( ( ) => allocator . Allocate < byte > ( 5 * oneMb ) ) ;
411
+ }
412
+
413
+ [ Fact ]
414
+ public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException ( )
415
+ {
416
+ MemoryAllocator allocator = MemoryAllocator . Create ( new MemoryAllocatorOptions ( )
417
+ {
418
+ AllocationLimitMegabytes = 4
419
+ } ) ;
420
+ const int oneMb = 1 << 20 ;
421
+ allocator . AllocateGroup < byte > ( 4 * oneMb , 1024 ) . Dispose ( ) ; // Should work
422
+ Assert . Throws < InvalidMemoryOperationException > ( ( ) => allocator . AllocateGroup < byte > ( 5 * oneMb , 1024 ) ) ;
423
+ }
424
+
401
425
#if NETCOREAPP3_1_OR_GREATER
402
426
[ Fact ]
403
427
public void Issue2001_NegativeMemoryReportedByGc ( )
You can’t perform that action at this time.
0 commit comments