I don't understand what you are trying to say. Note that your code uses unsafe.Pointer in an unsupported way. See https://golang.org/pkg/unsafe/#Pointer .
Ian On Thu, Mar 30, 2017 at 7:08 AM, 刘桂祥 <liuguixiang...@gmail.com> wrote: > package main > > import ( > "fmt" > "runtime" > "unsafe" > ) > > func main() { > var m runtime.MemStats > > runtime.ReadMemStats(&m) > println(m.HeapObjects, m.Mallocs) > > runtime.GC() > > runtime.ReadMemStats(&m) > println(m.HeapObjects, m.Mallocs) > > runtime.GC() > > runtime.ReadMemStats(&m) > println(m.HeapObjects, m.Mallocs) > > p := foo() > runtime.ReadMemStats(&m) > println(m.HeapObjects, m.Mallocs) > > runtime.GC() > > runtime.ReadMemStats(&m) > println(m.HeapObjects, m.Mallocs) > println(*((*int)(unsafe.Pointer(p)))) > > foo1() > > println(*((*int)(unsafe.Pointer(p)))) > } > > func foo() uintptr { > i := new(int) > *i = 1000 > if false { > fmt.Sprintf("%v", i) > } > > return uintptr(unsafe.Pointer(i)) > } > func foo1() uintptr { > i := new(int) > *i = 2000 > if false { > fmt.Sprintf("%v", i) > } > > return uintptr(unsafe.Pointer(i)) > } > > > > -- > 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. -- 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.