Go的GC打印出来的信息

环境

本文的go版本是 go1.8 linux/amd64。

启动程序

设置环境变量GODEBUG,然后启动程序。假如程序叫proc,则启动命令为:
GODEBUG=gctrace=1 ./proc

gc信息

gc打印的内容像这样的:
gc 1 @0.045s 22%: 4.6+182+0.38 ms clock, 9.2+0/96/86+0.77 ms cpu, 52->52->52 MB, 53 MB goal, 2 P
gc打印的信息格式大概如下:
gc # @#s #%: #+...+# ms clock, #+...+# ms cpu, #->#-># MB, # MB goal, # P
字段含义如下:

    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

参考:

http://stackoverflow.com/questions/20551748/decipher-golang-garbage-collection-output

你可能感兴趣的:(Go的GC打印出来的信息)