English 中文(简体)
Can the performance timer "% Time in GC" be wrong?
原标题:

We found that, since today, the "% Time in GC" (percent time in Garbage Collector) performance timer, steadily stood on 100% with only occasionally a bit lower. Even when at night no visitors were online.

Then I placed App_Offline.htm in the root. Usually this brings down all ASP.NET activity. But for some odd reason, the "% Time in GC", while lowered to 34%, remained steady.

Am I looking over something obvious here? Some other GC related performance counters also seem to still act, but marginally.

EDIT: I had written "only today", but it s really "since today". It hasn t gone away since.

最佳回答

Jrista pointed in the right direction with his answer, but the actual reason of this behavior turned out to be rather different:

The "% Time in GC" counter is not a realtime counter. Instead, it shows the last value measured when the last GC happened. When you close your web application with App_Offline.htm, the GC will run and take a certain percentage. After that, the CLR is totally inactive (the purpose os App_Offline), so no further garbage collections will happen and the percentage remains the same. Hence the straight line, even when ASP.NET CLR activity is zero.

Here s a description of this counter, which I copied here for reference (and to remind myself to read the explanation of a counter before asking silly questions).

% Time in GC is the percentage of elapsed time that was spent in performing a garbage collection (GC) since the last GC cycle. This counter is usually an indicator of the work done by the Garbage Collector on behalf of the application to collect and compact memory. This counter is updated only at the end of every GC and the counter value reflects the last observed value; its not an average.

问题回答

If the application is performing no work most of the time (say 1% of the time is actual work at individual moments throughout the day, but for the whole day it is more like .0000001%), then wouldn t that mean that, when work is being done, it is GC work? If there is only .0000001% of work being done by the web application for the whole day, then it certainly seems logical that 100% (for all intents and purposes) of the total work done for the whole day IS done by the GC. The GC will run periodically regardless of work being done, and if there is no other work being done...

Or am I misunderstanding the question?





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签