Memory Tracing
通过设置 GODEBUG
环境变量为 gctrace=1
可以让 golang 的 垃圾回收器 将每次 GC 的结果打印到标准错误输出。[1]
export GODEBUG=gctrace=1
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
若想拿到更细节的并发 pacer 的信息,可以设置 GODEBUG=gctrace=1,gcpacertrace=1
。