private static long CalculateMemoryPoolCeiling(int memoryBlockSize, long systemTotalPhysicalMemory)
{
long size = MemoryPool.MaximumTestedSupportedMemoryCeiling;
//Physical upper limit is
//the greater of
// 50% of memory
//or
// all but 8GB of RAM
long physicalUpperLimit = Math.Max(systemTotalPhysicalMemory / 2, systemTotalPhysicalMemory - 8 * 1024 * 1024 * 1024L);
size = Math.Min(size, physicalUpperLimit);
size = size - size % memoryBlockSize; //Rounds down to the nearest allocation size
return size;
}