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("\nAlloc = %v\tTotalAlloc = %v\tSys = %v\t NumGC = %v\n\n", float64(m.Alloc)/gb, float64(m.TotalAlloc)/gb, float64(m.Sys)/gb, m.NumGC) logger.Runtime.Info(logstr) } } }()