Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

c# - 非并发GC代替前景GC(NonConcurrentGC Instead of ForegroundGC)

I'm looking over the outcome of some simple C# code that just adds 10 mil elements to an ArrayList (efficiency is not the point, I just needed something that triggers GCs).

(我正在查看一些简单的C#代码的结果,这些代码仅向ArrayList中添加了1000万个元素(效率不是重点,我只需要触发GC的内容)。)

.NET Framework 4.7.2 is used.

(使用.NET Framework 4.7.2。)

GC is running in the default Concurrent Workstation mode, on a Windows 10 x64 OS.

(GC在Windows 10 x64 OS上以默认的并发工作站模式运行。)

BenchmarkDotNet (BDN) is used to profile the code and PerfView runs at the same time to collect GC info.

(BenchmarkDotNet(BDN)用于分析代码,PerfView同时运行以收集GC信息。)

I simply mention BDN since the induced GCs seen before and after the code runs are actually coming from it;

(我之所以仅提及BDN,是因为在代码运行之前和之后看到的诱导式GC实际上是来自于它。)

it plays no other role in the problem at hand.

(它在眼前的问题中没有其他作用。)

Looking over PerfView's GCStats data, and focusing only on one single run of the code, we get this output:

(查看PerfView的GCStats数据,仅关注一次代码运行,我们得到以下输出:)

在此处输入图片说明

Let's take a closer look for what happens during the last background GC ( 2B ), from within PerfView, by looking at the ETW events themselves:

(让我们通过查看ETW事件本身来仔细查看PerfView中最后一个后台GC( 2B )期间发生的情况:)

在此处输入图片说明

As expected, the gen2 GC triggers both a gen0 (red highlight) and a gen1 GC (green highlight).

(正如预期的那样,gen2 GC触发了gen0(红色突出显示)和gen1 GC(绿色突出显示)。)

Also, from Konrad Kokosa's book, "Pro .NET Memory Management": " Foreground GCs are regular Non-Concurrent GCs, during which Background GC is temporarily suspended "

(另外,在Konrad Kokosa的书“ Pro .NET内存管理”中:“ 前台GC是常规的非并行GC,在此期间临时暂停了后台GC ”)

In this context, why isn't the gen0 GC - reported as NonConcurrentGC - actually marked as ForegroundGC, just as the gen1 GC is ?

(在这种情况下, 为什么不像Gen1 GC一样将gen0 GC(报告为NonConcurrentGC)实际标记为ForegroundGC ?)

It's not a one-off thing either: the pattern of the BGC gen2 triggering one non-concurrent gen0 and a foreground gen1 GC is repeated.

(这也不是一次性的事情:重复触发非并发gen0和前台gen1 GC的BGC gen2模式。)

  ask by Mihai Albert translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...