golang GC 学习

1、GC performs sweep termination.(GC执行扫描终止
    a. Stop the world. This causes all Ps to reach a GC safe-point(STW。这将导致所有的P达到GC安全点).
    b. Sweep any unswept spans(清除任何未被清除的span).There will only be unswept spans if this GC cycle was forced before the expected time(如果在预期时间之前强制执行此GC循环,则只会出现未清除的span).

2. GC performs the "mark 1" sub-phase.In this sub-phase, Ps are allowed to locally cache parts of the work queue(GC执行“mark 1”子阶段。在该子阶段,允许Ps本地缓存部分工作队列).
a. Prepare for the mark phase by setting gcphase to _GCmark(from _GCoff), enabling the write barrier, enabling mutator assists, and enqueueing root mark jobs(将gcphase从_GCoff设置为_GCmark,启用写屏障,启用mutator辅助,跟标记任务入队列为mark阶段做准备). No objects may be scanned until all Ps have enabled the write barrier, which is accomplished using stop the world(通过STW,保证在所有的P启用写屏障前没有对象会被扫描到).
b. Start the world. From this point, GC work is done by mark workers started by the scheduler and by assists performed as part of allocation(从这一时刻开始,GC工作由调度程序启动的标记工作程序和作为分配的一部分执行的辅助程序完成). The write barrier shades both the overwritten pointer and the new pointer value for any pointer writes (see mbarrier.go for details)(写屏障回味任何指针写操作着色对覆盖的指针和新指针值(参见mbarrier.go,获取详细信息)). Newly allocated objects are immediately marked black(所有新分配的对象会被马上标记为黑色).
c. GC performs root marking jobs(GC执行跟标记任务). This includes scanning all stacks, shading all globals,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值