首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >破译垃圾收集输出

破译垃圾收集输出
EN

Stack Overflow用户
提问于 2013-12-12 18:48:44
回答 2查看 3.9K关注 0票数 6

我正在运行一个示例程序,使用

代码语言:javascript
复制
rahul@g3ck0:~/programs/Remodel$ GOGCTRACE=1 go run main.go 
gc1(1): 0+0+0 ms 0 -> 0 MB 422 -> 346 (422-76) objects 0 handoff
gc2(1): 0+0+0 ms 0 -> 0 MB 2791 -> 1664 (2867-1203) objects 0 handoff
gc3(1): 0+0+0 ms 1 -> 0 MB 4576 -> 2632 (5779-3147) objects 0 handoff
gc4(1): 0+0+0 ms 1 -> 0 MB 3380 -> 2771 (6527-3756) objects 0 handoff
gc5(1): 0+0+0 ms 1 -> 0 MB 3511 -> 2915 (7267-4352) objects 0 handoff
gc6(1): 0+0+0 ms 1 -> 0 MB 6573 -> 2792 (10925-8133) objects 0 handoff
gc7(1): 0+0+0 ms 1 -> 0 MB 4859 -> 3059 (12992-9933) objects 0 handoff
gc8(1): 0+0+0 ms 1 -> 0 MB 4554 -> 3358 (14487-11129) objects 0 handoff
gc9(1): 0+0+0 ms 1 -> 0 MB 8633 -> 4116 (19762-15646) objects 0 handoff
gc10(1): 0+0+0 ms 1 -> 0 MB 9415 -> 4769 (25061-20292) objects 0 handoff
gc11(1): 0+0+0 ms 1 -> 0 MB 6636 -> 4685 (26928-22243) objects 0 handoff
gc12(1): 0+0+0 ms 1 -> 0 MB 6741 -> 4802 (28984-24182) objects 0 handoff
gc13(1): 0+0+0 ms 1 -> 0 MB 9654 -> 5097 (33836-28739) objects 0 handoff
gc1(1): 0+0+0 ms 0 -> 0 MB 209 -> 171 (209-38) objects 0 handoff

帮助我理解第一部分,

0+0+0 =>标记+扫描+清洁时间

422 -> 346是否意味着内存已从422 MB清除到346 MB?如果是的话,那为什么在没有什么需要清理的时候,记忆就会减少呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-12 22:03:17

输出是从以下一行生成的:http://golang.org/src/pkg/runtime/mgc0.c?#L2147

所以不同的部分是:

  • 0+0+0 ms :在ms中标记、扫描和清除持续时间
  • 1 -> 0 MB :堆在MB之前和之后
  • 209 - 171 :前后的物体
  • (209-38)对象:分配和释放的数量

切换(以及在围棋1.2窃取和产量)是该算法的内部。

票数 4
EN

Stack Overflow用户

发布于 2015-08-19 22:06:32

在Go 1.5中,该输出的格式发生了很大变化。要获得完整的文档,请转到http://godoc.org/runtime并搜索"gctrace:“。

代码语言:javascript
复制
gctrace: setting gctrace=1 causes the garbage collector to emit a single line to standard
error at each collection, summarizing the amount of memory collected and the
length of the pause. Setting gctrace=2 emits the same summary but also
repeats each collection. The format of this line is subject to change.
Currently, it is:
    gc # @#s #%: #+...+# ms clock, #+...+# ms cpu, #->#-># MB, # MB goal, # P
where the fields are as follows:
    gc #        the GC number, incremented at each GC
    @#s         time in seconds since program start
    #%          percentage of time spent in GC since program start
    #+...+#     wall-clock/CPU times for the phases of the GC
    #->#-># MB  heap size at GC start, at GC end, and live heap
    # MB goal   goal heap size
    # P         number of processors used
The phases are stop-the-world (STW) sweep termination, scan,
synchronize Ps, mark, and STW mark termination. The CPU times
for mark are broken down in to assist time (GC performed in
line with allocation), background GC time, and idle GC time.
If the line ends with "(forced)", this GC was forced by a
runtime.GC() call and all phases are STW.
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20551748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档