File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/ImageSharp/Memory/Allocators
tests/ImageSharp.Tests/Memory/Allocators Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public static MemoryAllocator Create(MemoryAllocatorOptions options)
4949 UniformUnmanagedMemoryPoolMemoryAllocator allocator = new ( options . MaximumPoolSizeMegabytes ) ;
5050 if ( options . AllocationLimitMegabytes . HasValue )
5151 {
52- allocator . MemoryGroupAllocationLimitBytes = options . AllocationLimitMegabytes . Value * 1024 * 1024 ;
52+ allocator . MemoryGroupAllocationLimitBytes = options . AllocationLimitMegabytes . Value * 1024L * 1024L ;
5353 allocator . SingleBufferAllocationLimitBytes = ( int ) Math . Min ( allocator . SingleBufferAllocationLimitBytes , allocator . MemoryGroupAllocationLimitBytes ) ;
5454 }
5555
Original file line number Diff line number Diff line change @@ -442,4 +442,20 @@ public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException()
442442 allocator . AllocateGroup < byte > ( 4 * oneMb , 1024 ) . Dispose ( ) ; // Should work
443443 Assert . Throws < InvalidMemoryOperationException > ( ( ) => allocator . AllocateGroup < byte > ( 5 * oneMb , 1024 ) ) ;
444444 }
445+
446+ [ ConditionalFact ( typeof ( Environment ) , nameof ( Environment . Is64BitProcess ) ) ]
447+ public void MemoryAllocator_Create_SetHighLimit ( )
448+ {
449+ RemoteExecutor . Invoke ( RunTest ) . Dispose ( ) ;
450+ static void RunTest ( )
451+ {
452+ const long threeGB = 3L * ( 1 << 30 ) ;
453+ MemoryAllocator allocator = MemoryAllocator . Create ( new MemoryAllocatorOptions ( )
454+ {
455+ AllocationLimitMegabytes = ( int ) ( threeGB / 1024 )
456+ } ) ;
457+ using MemoryGroup < byte > memoryGroup = allocator . AllocateGroup < byte > ( threeGB , 1024 ) ;
458+ Assert . Equal ( threeGB , memoryGroup . TotalLength ) ;
459+ }
460+ }
445461}
You can’t perform that action at this time.
0 commit comments