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)
}
go run example2.go
32744 65
4228984 76
sorry add this to example2.go and the results is a little different but
I also don't konw the reason to the results
在 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 [email protected].
For more options, visit https://groups.google.com/d/optout.