package main import "runtime"
func init() { runtime.MemProfileRate = 1 } func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) cap := 1024 * 1024 * 4 s := make([]byte, cap) _ = s runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) } I add this to example2.go but the results is the same . Did I use right ?? 在 2016年9月29日星期四 UTC+8下午5:07:23,Dave Cheney写道: > > One way to do this might be to enable memory profiling in your program > with the rate set to 1. Hopefully this will record the stack trace of every > allocation. The data may need some interpretation -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.