Re: [go-nuts] Why array [10485761]bytes (10MB) moved to the heap?

2018-04-13 Thread Ian Lance Taylor
On Fri, Apr 13, 2018 at 2:07 PM, Yulrizka wrote: > > I'm playing around with slices. > Found that slice of bytes with the size more than 10485760 is moved to the > heap. Because Go stacks are copied as needed, there is a tradeoff between putting a value on the stack and putting it on the heap. O

[go-nuts] Why array [10485761]bytes (10MB) moved to the heap?

2018-04-13 Thread Yulrizka
I'm playing around with slices. Found that slice of bytes with the size more than 10485760 is moved to the heap. package main import ( "fmt" "runtime/debug" "time" ) // run with escape analysis // go run -gcflags '-m -l' main.go func main() { a() fmt.Println("after a returned") debug