GSF.IO.Unmanaged.MemoryPoolPageList.CalculateMemoryBlockSize C# (CSharp) Method

CalculateMemoryBlockSize() private static method

Calculates the desired allocation block size to request from the OS.
The recommended block size is the totalSystemMemory divided by 1000 but must be a multiple of the system allocation size and the page size and cannot be larger than 1GB
private static CalculateMemoryBlockSize ( int pageSize, long totalSystemMemory ) : int
pageSize int the size of each page
totalSystemMemory long the total amount of system memory
return int
        private static int CalculateMemoryBlockSize(int pageSize, long totalSystemMemory)
        {
            long targetMemoryBlockSize = totalSystemMemory / 1000;
            targetMemoryBlockSize = Math.Min(targetMemoryBlockSize, 1024 * 1024 * 1024);
            targetMemoryBlockSize = targetMemoryBlockSize - (targetMemoryBlockSize % pageSize);
            targetMemoryBlockSize = (int)Math.Max(targetMemoryBlockSize, pageSize);
            targetMemoryBlockSize = (int)BitMath.RoundUpToNearestPowerOfTwo((ulong)targetMemoryBlockSize);
            return (int)targetMemoryBlockSize;
        }