Go 使用什么样的垃圾收集?
Go 是一种垃圾收集语言:
http://golang.org/doc/go_faq.html#garbage_collection
在这里说它是一个标记和清除垃圾收集器,但它没有深入研究细节,并且替代品正在开发中......然而,自从 Go 发布以来,这一段似乎没有更新太多。
仍然是标记和清除吗?是保守的还是精确的?是一代人的吗?
Go is a garbage collected language:
http://golang.org/doc/go_faq.html#garbage_collection
Here it says that it's a mark-and-sweep garbage collector, but it doesn't delve into details, and a replacement is in the works... yet, this paragraph seems not to have been updated much since Go was released.
It's still mark-and-sweep? Is it conservative or precise? Is it generational?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Go 1.4+ 垃圾收集器的计划:
Go 1.3 垃圾收集器在 Go 1.1 之上进行更新:
Go 1.1 垃圾收集器:
Go 1.0 垃圾收集器:
用不同的GC替换GC是有争议的,例如:
Plans for Go 1.4+ garbage collector:
Go 1.3 garbage collector updates on top of Go 1.1:
Go 1.1 garbage collector:
Go 1.0 garbage collector:
Replacing the GC with a different one is controversial, for example:
(对于 Go 1.8 - 2017 年第一季度,请参阅下文)
下一个 Go 1.5 并发垃圾收集器涉及gc 说,能够“步调”。
这是本文中提出的一项提案,可能会适用于 Go 1.5,但也有助于理解中的 gc去。
您可以看到 1.5 之前的状态(Stop The World:STW)
(照片来自 GopherCon 2015 演示文稿“Go GC:解决 Go 中的延迟问题1.5")
STW 收集器的唯一调节旋钮是“GOGC”,即收集之间的相对堆增长。默认设置 100% 每当堆大小比上次收集时的实时堆大小增加一倍时就会触发垃圾收集:
STW 收集器中的 GC 计时。
(照片来自 GopherCon 2015 演示文稿“Go GC:解决 Go 中的延迟问题1.5")
(For Go 1.8 - Q1 2017, see below)
The next Go 1.5 concurrent Garbage Collector involve being able to "pace" said gc.
Here is a proposal presented in this paper which might make it for Go 1.5, but also helps understand the gc in Go.
You can see the state before 1.5 (Stop The World: STW)
(Photo from GopherCon 2015 presentation "Go GC: Solving the Latency Problem in Go 1.5")
The sole tuning knob for the STW collector was “GOGC”, the relative heap growth between collections. The default setting, 100%, triggered garbage collection every time the heap size doubled over the live heap size as of the previous collection:
GC timing in the STW collector.
(Photo from GopherCon 2015 presentation "Go GC: Solving the Latency Problem in Go 1.5")
这是 GC 的实现:
https://github.com /golang/go/blob/master/src/runtime/mgc.go
来自源中的文档:
This is the implementation of the GC:
https://github.com/golang/go/blob/master/src/runtime/mgc.go
From the docs in the source:
Go 1.8 GC 可能会再次发展,提案“消除 STW”堆栈重新扫描”
公告在此,您可以查看相关来源提交是d70b0fe 及更早版本。
Go 1.8 GC might evolve again, with the proposal "Eliminate STW stack re-scanning"
The announcement is here and you can see the relevant source commit is d70b0fe and earlier.
我不确定,但我认为当前(提示)GC 已经是并行的,或者至少是一个 WIP。因此,停止世界属性不再适用或在不久的将来也不会适用。也许其他人可以更详细地澄清这一点。
I'm not sure, but I think the current (tip) GC is already a parallel one or at least it's a WIP. Thus the stop-the-world property doesn't apply any more or will not in the near future. Perhaps someone other can clarify this in more detail.