56 if (sizeInMegabytes <= 0)
66 ulong num3 = (ulong)(
Math.
Ceiling((
double)sizeInMegabytes / 16.0) * 16.0);
68 for (
int i = 0; i < 3; i++)
75 ulong num4 = num2 + memoryFailPointReservedMemory;
76 bool flag = num4 < num2 || num4 < memoryFailPointReservedMemory;
77 bool flag2 = availPageFile < num3 + memoryFailPointReservedMemory + 16777216 || flag;
78 bool flag3 = totalAddressSpaceFree < num4 || flag;
85 if (!flag2 && !flag3 && !flag4)
152 return (ulong)(long)lpSystemInfo.lpMaximumApplicationAddress;
162 totalAddressSpaceFree = 0uL;
174 if (num2 < size && shouldThrow)
196 ulong num2 = lpBuffer.RegionSize.ToUInt64();
197 if (lpBuffer.State == 65536)
205 address = (
void*)((ulong)address + num2);
static UIntPtr VirtualQuery(SafeHandle lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength)
static IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect)
static void GetSystemInfo(out SYSTEM_INFO lpSystemInfo)
static unsafe bool VirtualFree(void *lpAddress, UIntPtr dwSize, int dwFreeType)
static unsafe BOOL GlobalMemoryStatusEx(MEMORYSTATUSEX *lpBuffer)
static void SuppressFinalize(object obj)
static ulong GetSegmentSize()
static void Collect(int generation)
static Exception GetExceptionForLastWin32Error(string path="")
static double Ceiling(double a)
static byte Max(byte val1, byte val2)
static long LastKnownFreeAddressSpace
static unsafe void CheckForFreeAddressSpace(ulong size, bool shouldThrow)
static long s_failPointReservedMemory
readonly ulong _reservedMemory
static unsafe void GrowPageFileIfNecessaryAndPossible(UIntPtr numBytes)
static unsafe bool CheckForAvailableMemory(out ulong availPageFile, out ulong totalAddressSpaceFree)
static long s_hiddenLastKnownFreeAddressSpace
static unsafe ulong MemFreeAfterAddress(void *address, ulong size)
static long AddMemoryFailPointReservation(long size)
static void AddToLastKnownFreeAddressSpace(long addend)
bool _mustSubtractReservation
static ulong GetTopOfMemory()
MemoryFailPoint(int sizeInMegabytes)
static ulong MemoryFailPointReservedMemory
static long s_hiddenLastTimeCheckingAddressSpace
static readonly ulong s_topOfMemory
static readonly ulong s_GCSegmentSize
static long LastTimeCheckingAddressSpace
void Dispose(bool disposing)
static string InsufficientMemory_MemFailPoint
static string InsufficientMemory_MemFailPoint_TooBig
static string ArgumentOutOfRange_NeedNonNegNum
static string InsufficientMemory_MemFailPoint_VAFrag
static int Add(ref int location1, int value)
static bool Read(ref bool location)
static void Write(ref bool location, bool value)
static readonly UIntPtr Zero