Događaj
Izgradite inteligentne aplikacije
17. mar 21 - 21. mar 10
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahOvaj pregledač više nije podržan.
Nadogradite na Microsoft Edge biste iskoristili najnovije funkcije, bezbednosne ispravke i tehničku podršku.
To reclaim objects, the garbage collector (GC) must stop all the executing threads in an application. The period of time during which the garbage collector is active is referred to as its latency.
In some situations, such as when an application retrieves data or displays content, a full garbage collection can occur at a critical time and impede performance. You can adjust the intrusiveness of the garbage collector by setting the GCSettings.LatencyMode property to one of the System.Runtime.GCLatencyMode values.
Using a "low" latency setting means the garbage collector intrudes less in your application. Garbage collection is more conservative about reclaiming memory.
The System.Runtime.GCLatencyMode enumeration provides two low latency settings:
GCLatencyMode.LowLatency suppresses generation 2 collections and performs only generation 0 and 1 collections. It can be used only for short periods of time. Over longer periods, if the system is under memory pressure, the garbage collector will trigger a collection, which can briefly pause the application and disrupt a time-critical operation. This setting is available only for workstation garbage collection.
GCLatencyMode.SustainedLowLatency suppresses foreground generation 2 collections and performs only generation 0, 1, and background generation 2 collections. It can be used for longer periods of time, and is available for both workstation and server garbage collection. This setting cannot be used if background garbage collection is disabled.
During low latency periods, generation 2 collections are suppressed unless the following occurs:
The system receives a low memory notification from the operating system.
Application code induces a collection by calling the GC.Collect method and specifying 2 for the generation
parameter.
The following table lists the application scenarios for using the GCLatencyMode values:
Latency mode | Application scenarios |
---|---|
Batch | For applications that have no user interface (UI) or server-side operations. When background garbage collection is disabled, this is the default mode for workstation and server garbage collection. Batch mode also overrides the gcConcurrent setting, that is, it prevents background or concurrent collections. |
Interactive | For most applications that have a UI. This is the default mode for workstation and server garbage collection. However, if an app is hosted, the garbage collector settings of the hosting process take precedence. |
LowLatency | For applications that have short-term, time-sensitive operations during which interruptions from the garbage collector could be disruptive. For example, applications that render animations or data acquisition functions. |
SustainedLowLatency | For applications that have time-sensitive operations for a contained but potentially longer duration of time during which interruptions from the garbage collector could be disruptive. For example, applications that need quick response times as market data changes during trading hours. This mode results in a larger managed heap size than other modes. Because it does not compact the managed heap, higher fragmentation is possible. Ensure that sufficient memory is available. |
When you use GCLatencyMode.LowLatency mode, consider the following guidelines:
Keep the period of time in low latency as short as possible.
Avoid allocating high amounts of memory during low latency periods. Low memory notifications can occur because garbage collection reclaims fewer objects.
While in the low latency mode, minimize the number of new allocations, in particular allocations onto the large object heap and pinned objects.
Be aware of threads that could be allocating. Because the LatencyMode property setting is process-wide, OutOfMemoryException exceptions can be generated on any thread that is allocating.
Wrap the low latency code in constrained execution regions. For more information, see Constrained execution regions.
You can force generation 2 collections during a low latency period by calling the GC.Collect(Int32, GCCollectionMode) method.
Povratne informacije za .NET
.NET je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije:
Događaj
Izgradite inteligentne aplikacije
17. mar 21 - 21. mar 10
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahObuka
Putanja učenja
Run high-performance computing (HPC) applications on Azure - Training
Azure HPC is a purpose-built cloud capability for HPC & AI workload, using leading-edge processors and HPC-class InfiniBand interconnect, to deliver the best application performance, scalability, and value. Azure HPC enables users to unlock innovation, productivity, and business agility, through a highly available range of HPC & AI technologies that can be dynamically allocated as your business and technical needs change. This learning path is a series of modules that help you get started on Azure HPC - you