44 if (kind < GCKind.Any || kind >
GCKind.Background)
54 internal static extern int _StartNoGCRegion(
long totalSize,
bool lohSizeKnown,
long lohSize,
bool disallowFullBlockingGC);
69 private static extern void _Collect(
int generation,
int mode);
94 if (bytesAllocated <= 0)
106 if (bytesAllocated <= 0)
131 Collect(generation, mode, blocking:
true);
136 Collect(generation, mode, blocking, compacting:
false);
162 else if (!compacting)
226 if (!forceFullCollection)
231 long num2 = totalMemory;
239 num3 = (float)(num2 - totalMemory) / (float)totalMemory;
241 while (num-- > 0 && (!(-0.05 < (
double)num3) || !((double)num3 < 0.05)));
271 if (maxGenerationThreshold <= 0 || maxGenerationThreshold >= 100)
275 if (largeObjectHeapThreshold <= 0 || largeObjectHeapThreshold >= 100)
321 private static bool StartNoGCRegionWorker(
long totalSize,
bool hasLohSize,
long lohSize,
bool disallowFullBlockingGC)
333 if (lohSize > totalSize)
340 StartNoGCRegionStatus.NotEnoughMemory =>
false,
341 StartNoGCRegionStatus.AlreadyInProgress =>
throw new InvalidOperationException(
"The NoGCRegion mode was already in progress"),
342 StartNoGCRegionStatus.AmountTooLarge =>
throw new ArgumentOutOfRangeException(
"totalSize",
"totalSize is too large. For more information about setting the maximum size, see \"Latency Modes\" in https://go.microsoft.com/fwlink/?LinkId=522706"),
398 return AllocateNewUninitializedArray(
length, pinned);
399 static T[] AllocateNewUninitializedArray(
int length,
bool pinned)
static long GetTotalAllocatedBytes(bool precise=false)
static int _WaitForFullGCApproach(int millisecondsTimeout)
static void AddMemoryPressure(long bytesAllocated)
static int _EndNoGCRegion()
static int CollectionCount(int generation)
static IntPtr _RegisterFrozenSegment(IntPtr sectionAddress, nint sectionSize)
static void _WaitForPendingFinalizers()
static bool TryStartNoGCRegion(long totalSize, bool disallowFullBlockingGC)
static long GetAllocatedBytesForCurrentThread()
static void RegisterForFullGCNotification(int maxGenerationThreshold, int largeObjectHeapThreshold)
static int _WaitForFullGCComplete(int millisecondsTimeout)
static bool _CancelFullGCNotification()
static int _CollectionCount(int generation, int getSpecialGCCount)
static ulong GetGenerationSize(int gen)
static long GetTotalMemory()
static void SuppressFinalize(object obj)
static GCMemoryInfo GetGCMemoryInfo(GCKind kind)
static void _UnregisterFrozenSegment(IntPtr segmentHandle)
static GCMemoryInfo GetGCMemoryInfo()
static void _RemoveMemoryPressure(ulong bytesAllocated)
static GCNotificationStatus WaitForFullGCComplete(int millisecondsTimeout)
static int GetGeneration(WeakReference wo)
static GCNotificationStatus WaitForFullGCApproach(int millisecondsTimeout)
static void RemoveMemoryPressure(long bytesAllocated)
static GCNotificationStatus WaitForFullGCApproach()
static int GetLastGCPercentTimeInGC()
static void _ReRegisterForFinalize(object o)
static int GetMaxGeneration()
static int GetGeneration(object obj)
static int _StartNoGCRegion(long totalSize, bool lohSizeKnown, long lohSize, bool disallowFullBlockingGC)
static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
static void _SuppressFinalize(object o)
static ulong GetSegmentSize()
static void Collect(int generation)
static GCNotificationStatus WaitForFullGCComplete()
static int GetGenerationWR(IntPtr handle)
static Array AllocateNewArray(IntPtr typeHandle, int length, GC_ALLOC_FLAGS flags)
static bool _RegisterForFullGCNotification(int maxGenerationPercentage, int largeObjectHeapPercentage)
static void GetMemoryInfo(GCMemoryInfoData data, int kind)
static T[] AllocateArray< T >(int length, bool pinned=false)
static void _AddMemoryPressure(ulong bytesAllocated)
static bool TryStartNoGCRegion(long totalSize)
@ GC_ALLOC_ZEROING_OPTIONAL
@ GC_ALLOC_PINNED_OBJECT_HEAP
static bool TryStartNoGCRegion(long totalSize, long lohSize, bool disallowFullBlockingGC)
static void KeepAlive(object? obj)
static void EndNoGCRegion()
static void Collect(int generation, GCCollectionMode mode, bool blocking)
static bool TryStartNoGCRegion(long totalSize, long lohSize)
static long GetTotalMemory(bool forceFullCollection)
static void _Collect(int generation, int mode)
static T[] AllocateUninitializedArray< T >(int length, bool pinned=false)
static void ReRegisterForFinalize(object obj)
static void Collect(int generation, GCCollectionMode mode)
static void WaitForPendingFinalizers()
static void Collect(int generation, GCCollectionMode mode, bool blocking, bool compacting)
static void CancelFullGCNotification()
static string ArgumentOutOfRange_NeedPosNum
static string ArgumentOutOfRange_Enum
static string Format(string resourceFormat, object p1)
static string InvalidOperation_NotWithConcurrentGC
static string ArgumentOutOfRange_NeedNonNegOrNegative1
static string ArgumentOutOfRange_GenericPositive
static string ArgumentOutOfRange_Bounds_Lower_Upper
static void ThrowInvalidTypeWithPointersNotSupported(Type targetType)