GC.RefreshMemoryLimit Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Instructs the Garbage Collector to reconfigure itself by detecting the various memory limits on the system.
public:
static void RefreshMemoryLimit();
public static void RefreshMemoryLimit ();
static member RefreshMemoryLimit : unit -> unit
Public Shared Sub RefreshMemoryLimit ()
The hard limit is too low. This can happen if the heap hard limit that the refresh will set, either because of new AppData settings or implied by the container memory-limit changes, is lower than what's already committed.
-or-
The hard limit is invalid. This can happen, for example, with negative heap hard-limit percentages.
In addition to actual physical memory limit and container-limit settings, these configuration settings can be overwritten:
- GCHeapHardLimit
- GCHeapHardLimitPercent
- GCHeapHardLimitSOH
- GCHeapHardLimitLOH
- GCHeapHardLimitPOH
- GCHeapHardLimitSOHPercent
- GCHeapHardLimitLOHPercent
- GCHeapHardLimitPOHPercent
Instead of updating the environment variable (which won't be read), these override these settings by using a ulong value in the AppContext.
For example, you can use AppContext.SetData("GCHeapHardLimit", (ulong) 100 * 1024 * 1024)
to override the GCHeapHardLimit to 100M.
This API only handles configs that can be handled when the runtime is loaded. For configs that don't have any effects on 32-bit systems (like the GCHeapHardLimit* ones), this API will not handle it.
Product | Versions |
---|---|
.NET | 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: