Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of "% Time in GC" performance counter

I'm using the perfcounter = "% Time in GC"

So when I run

gcPerf.NextSample() 

I get the value 42.12273.

But I don't understand the units of this values is it in (ms) or what ?

If I want it in (ms) how I can transform it ?

Here is the global code

 string category = ".NET CLR Memory";
 string counter  = "% Time in GC";
 string instance = Process.GetCurrentProcess().ProcessName;
 PerformanceCounter gcPerf;

 // make sure the performance counter is available to query
 if (PerformanceCounterCategory.Exists(category) &&
     PerformanceCounterCategory.CounterExists(counter, category) &&
     PerformanceCounterCategory.InstanceExists(instance, category))
 {
    gcPerf = new PerformanceCounter(category, counter, instance);
 }
like image 497
miloud Avatar asked Jul 22 '15 17:07

miloud


1 Answers

This is the percentage of the time spent in GC since the end of the last GC. For example, it’s been 1 million cycles since last GC ended and we spent 0.3 million cycles in the current GC, this counter will show 30%.

Read this and this.

What is a health value for this counter? It’s hard to say. It depends on what your app does. But if you are seeing a really high value (like 50% or more) then it’s a reasonable time to look at what’s going on inside of the managed heap. If this number is 10%, it’s probably better to look elsewhere in your app because even if you could get rid of half of that, you would only be saving 5% - most likely not very worthwhile.

like image 143
CharithJ Avatar answered Nov 02 '22 23:11

CharithJ