英文:
why foreground garbage collection doesn't collect when a GC is triggered?
问题
Q1. 线程1上的红色箭头代表什么意思?我觉得它表示线程1触发了垃圾收集,但如果是这样的话,为什么GC线程1和GC线程2在这个窗口没有执行前台垃圾收集?为什么专用的GC线程在应用程序线程1、2、3暂停时没有进行收集?
Q2. 什么导致线程1、2、3再次被暂停?我觉得是后台线程1、2执行第2代收集并暂停线程1、2、3以清理堆对象,但为什么这些后台线程在线程1、2、3恢复后仍在执行(你可以看到红色BGC线程的时间戳比线程1、2、3的蓝色暂停时间戳更长)。
英文:
Below is a screenshot from
https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/background-gc
we know that background garbage collection is performed on one or more dedicated threads, depending on whether it's workstation or server GC, and applies only to generation 2 collections. and foreground garbage collection does generation 0 and 1 collections
my questions in regards to the picture are:
Q1. the red arrow in thread 1, what does "init GC" mean? I feel like it means thread 1 triggers a GC, but if this is the case, why GC thread 1 and GC thread 2 don't do foreground garbage collection at this window? why dedicated GC threads are not collecting when appication thread 1, 2, 3 are suspended?
Q2. What makes thread 1, 2, 3 suspended again? I feel likt it i the background thread 1, 2 doing generation 2 collection and suspends thread 1, 2, 3 to sweep heap objects, but why those background threads are still collecting after thread 1, 2, 3 are resumed (you can see that the red BGC Thread timestamp is longer than the blue suspended timestamp of thread 1, 2, 3)
答案1
得分: 0
在BGC(后台垃圾回收)中,由于每个BGC会暂停两次,因此有两个持续时间 - 一个是初始暂停,第二个是在标记阶段结束时(在mem-doc中的GC事件序列部分有描述)。
链接:https://devblogs.microsoft.com/dotnet/the-updated-getgcmemoryinfo-api-in-net-5-0-and-how-it-can-help-you/
英文:
Q2:
> or BGCs there are 2 durations since each BGC will pause twice – one is the initial pause and the 2nd one is at the end of the mark phase (described in the GC event sequence section in mem-doc).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论