性能计时器“% Time in GC”可以设置吗?有错吗?
我们发现,从今天开始,“% Time in GC”(垃圾收集器中的时间百分比)性能计时器稳定地保持在 100%,只是偶尔会稍低一些。即使在晚上也没有访客在线。
然后我将 App_Offline.htm
放在根目录中。通常这会导致所有 ASP.NET 活动停止。但由于某些奇怪的原因,“GC 时间百分比” 虽然降低至 34%,但仍保持稳定。
我在这里寻找明显的东西吗?其他一些与 GC 相关的性能计数器似乎仍然起作用,但作用不大。
编辑:我写的是“只有今天”,但实际上是“从今天开始”。从那以后它就没有消失过。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jrista 指出了正确的方向与他的回答不同,但这种行为的实际原因却大不相同:
“% Time in GC” 计数器不是实时计数器。相反,它显示上次 GC 发生时测量的最后一个值。当您使用
App_Offline.htm
关闭 Web 应用程序时,GC 将运行并占用一定的百分比。之后,CLR 完全不活动(App_Offline 的目的),因此不会发生进一步的垃圾收集,并且百分比保持不变。因此,即使 ASP.NET CLR 活动为零,也是直线。这是这个计数器的描述,我复制在这里供参考(并提醒自己在问愚蠢的问题之前先阅读计数器的解释)。
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).
如果应用程序大部分时间都不执行任何工作(假设 1% 的时间是一天中各个时刻的实际工作,但对于一整天来说,它更像是 0.0000001%),那么这是否意味着,当工作完成时,是GC工作吗?如果 Web 应用程序一整天只完成了 0.0000001% 的工作,那么全天完成的总工作的 100%(出于所有意图和目的)由 GC 完成似乎是合乎逻辑的。无论正在完成什么工作,GC 都会定期运行,并且如果没有其他工作正在完成......
或者我是否误解了这个问题?
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?