go build -gcflags '-N -l' example.go && ./example
If I use this to compile example.go it shound disable function inline and 
the compile code should call ref() in example.go and will call mallocgc 
runtimestats.Mallocs can see it  but it is not.

在 2017年4月14日星期五 UTC+8下午10:01:25,Ian Lance Taylor写道:
>
> On Thu, Apr 13, 2017 at 10:45 PM, 刘桂祥 <liuguix...@gmail.com <javascript:>> 
> wrote: 
> > go1.7.1 
> > 
> > go run -gcflags '-N -l -m' example.go 
>
> It is the -m flag that is generating the output you see. 
>
> If there is some other bug, please let us know what it is. 
>
> Ian 
>
> > 在 2017年4月14日星期五 UTC+8下午1:18:26,Ian Lance Taylor写道: 
> >> 
> >> On Thu, Apr 13, 2017 at 8:33 PM, 刘桂祥 <liuguix...@gmail.com> wrote: 
> >> > // example.go 
> >> > package main 
> >> > 
> >> > 
> >> > import "runtime" 
> >> > 
> >> > 
> >> > type S struct{} 
> >> > 
> >> > 
> >> > func main() { 
> >> >  var stats runtime.MemStats 
> >> > 
> >> > 
> >> >  runtime.ReadMemStats(&stats) 
> >> >  println(stats.Mallocs) 
> >> >  var x S 
> >> >  runtime.ReadMemStats(&stats) 
> >> >  println(stats.Mallocs) 
> >> >  _ = *ref(x) 
> >> >  runtime.ReadMemStats(&stats) 
> >> >  println(stats.Mallocs) 
> >> > } 
> >> > 
> >> > 
> >> > func ref(z S) *S { 
> >> >  return &z 
> >> > } 
> >> > 
> >> > go build -gcflags '-N -l' example.go && ./example 
> >> > or 
> >> > go run -gcflags '-N -l' example.go 
> >> > 
> >> > results: 
> >> > ./example.go:21: &z escapes to heap 
> >> > ./example.go:20: moved to heap: z 
> >> > ./example.go:10: main &stats does not escape 
> >> > ./example.go:13: main &stats does not escape 
> >> > ./example.go:16: main &stats does not escape 
> >> > 61 
> >> > 61 
> >> > 61 
> >> 
> >> That looks like the output from -gcflags="-m -l".  Are you really sure 
> >> you typed -N?  What version of Go are you using? 
> >> 
> >> Ian 
> > 
> > -- 
> > 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...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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.

Reply via email to