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)
49
49
UniformUnmanagedMemoryPoolMemoryAllocator allocator = new ( options . MaximumPoolSizeMegabytes ) ;
50
50
if ( options . AllocationLimitMegabytes . HasValue )
51
51
{
52
- allocator . MemoryGroupAllocationLimitBytes = options . AllocationLimitMegabytes . Value * 1024 * 1024 ;
52
+ allocator . MemoryGroupAllocationLimitBytes = options . AllocationLimitMegabytes . Value * 1024L * 1024L ;
53
53
allocator . SingleBufferAllocationLimitBytes = ( int ) Math . Min ( allocator . SingleBufferAllocationLimitBytes , allocator . MemoryGroupAllocationLimitBytes ) ;
54
54
}
55
55
Original file line number Diff line number Diff line change @@ -442,4 +442,20 @@ public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException()
442
442
allocator . AllocateGroup < byte > ( 4 * oneMb , 1024 ) . Dispose ( ) ; // Should work
443
443
Assert . Throws < InvalidMemoryOperationException > ( ( ) => allocator . AllocateGroup < byte > ( 5 * oneMb , 1024 ) ) ;
444
444
}
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
+ }
445
461
}
You can’t perform that action at this time.
0 commit comments