[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 刘桂祥
if use go1.7 in runtime/malloc.go file add mallocgc debug info and go install and go run x.goI will get a error "signal: segmentation fault" in go1.4.2 will not func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { println("mallocgc:size=", size, "kind=", typ.kind, "nee

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread Dave Cheney
You should use Go 1.7.1 or later. On Thursday, 29 September 2016 23:00:25 UTC+10, 刘桂祥 wrote: > > package main > > import "runtime" > > func main() { > m := new(runtime.MemStats) > runtime.ReadMemStats(m) > cap := 1024 > println("debug0") > s := make([]byte, cap) > println(

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 刘桂祥
package main import "runtime" func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) cap := 1024 println("debug0") s := make([]byte, cap) println("debug1") _ = s runtime.ReadMemStats(m) println("memstats:", m.Alloc, m.Mallocs) } I use go1.4.2 and In

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread Dave Cheney
Sorry, you'll have to work harder to generate a memory profile. My github.com/pkg/profile package may help automate some of the work, but may introduce a few allocations of its own which you will have to filter out. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 刘桂祥
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.

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 刘桂祥
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.

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 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.

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread 刘桂祥
In my two examples, I use variable in makeslice that it will all escape to the heap , But I just want to use runtime.ReadMemStats to lookup it and find strange