性能计时器“% Time in GC”可以设置吗?有错吗?

发布于 2024-08-13 07:20:19 字数 326 浏览 2 评论 0原文

我们发现,从今天开始,“% 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吐个泡泡 2024-08-20 07:20:19

Jrista 指出了正确的方向与他的回答不同,但这种行为的实际原因却大不相同:

“% Time in GC” 计数器不是实时计数器。相反,它显示上次 GC 发生时测量的最后一个值。当您使用 App_Offline.htm 关闭 Web 应用程序时,GC 将运行并占用一定的百分比。之后,CLR 完全不活动(App_Offline 的目的),因此不会发生进一步的垃圾收集,并且百分比保持不变。因此,即使 ASP.NET CLR 活动为零,也是直线。

这是这个计数器的描述,我复制在这里供参考(并提醒自己在问愚蠢的问题之前先阅读计数器的解释)。

% GC 时间是
所花费的时间
执行垃圾收集 (GC)
自上次 GC 周期以来。这个柜台
通常是工作的指标
由垃圾收集器完成
代表申请领取
和紧凑的内存。这个计数器是
仅在每次 GC 结束时更新
计数器值反映了
最后观察到的值;它不是一个
平均。

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.

永不分离 2024-08-20 07:20:19

如果应用程序大部分时间都不执行任何工作(假设 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文