web服务中加入如下
import ( "runtime" "time" "fmt" ) go func() { for { var m runtime.MemStats tick := time.After(5 * time.Second) select { case <-tick: runtime.ReadMemStats(&m) gb := 1024 * 1024 * 1024.0 logstr := fmt.Sprintf(" Alloc = %v TotalAlloc = %v Sys = %v NumGC = %v ", float64(m.Alloc)/gb, float64(m.TotalAlloc)/gb, float64(m.Sys)/gb, m.NumGC) logger.Runtime.Info(logstr) } } }()