Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if concurrent GC is running in .Net

Is there a straightforward function call to determine if Concurrent GC has been enabled in the runtime I'm running in? We have a heterogeneous environment and we need to log which mode is being used so we can identify which systems need to be modified.

I realise that I can investigate the exe.config and check it manually, I was just wondering if there is a property sitting somewhere that exposes this info without having to make a hack.

like image 524
Spence Avatar asked Jul 29 '13 04:07

Spence


People also ask

Who performs garbage collection in .NET core?

In this chapter, we will cover the concept of Garbage collection which is one of most important features of the . NET managed code platform. The garbage collector (GC) manages the allocation and release of memory. The garbage collector serves as an automatic memory manager.

How the garbage collector works in C#?

The garbage collector serves as an automatic memory manager. You do not need to know how to allocate and release memory or manage the lifetime of the objects that use that memory. An allocation is made any time you declare an object with a “new” keyword or a value type is boxed. Allocations are typically very fast.

What is concurrent GC?

Concurrent garbage collection enables interactive applications to be more responsive by minimizing pauses for a collection. Managed threads can continue to run most of the time while the concurrent garbage collection thread is running. This design results in shorter pauses while a garbage collection is occurring.

When an asp net core app starts the GC?

Application level singletons generally migrate to generation 2. When an ASP.NET Core app starts, the GC: Reserves some memory for the initial heap segments. Commits a small portion of memory when the runtime is loaded.


1 Answers

If System.Runtime.GCSettings.LatencyMode has the value LatencyMode.Batch then concurrent GC has been disabled.

like image 145
springy76 Avatar answered Sep 20 '22 03:09

springy76