Thanks for the explanation. On Friday, May 21, 2021 at 4:16:45 PM UTC-4 Ian Lance Taylor wrote:
> On Fri, May 21, 2021 at 7:46 AM tapi...@gmail.com <tapi...@gmail.com> > wrote: > > > > From the outputs of the following program, > > it looks the stack of a goroutine doesn't shrink immediately. > > Will it shrink at some point eventually? > > > > > > package main > > > > func f(i int) byte { > > type T int // avoid f being inline > > var a [1<<20]byte // make stack grow > > return a[i] > > } > > > > func main(){ > > var x int > > println(&x) // 0xc000034770 > > f(100) > > println(&x) // 0xc0002fff70 > > > > // It looks the stack hasn't shrunk here. > > > > f(100) > > println(&x) // 0xc0002fff70 > > } > > Stack shrinking occurs during garbage collection, and only if the > goroutine isn't doing anything and isn't sitting in a system call or a > cgo call. > > 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/cbf3fb87-13ed-44e8-96db-e7e8c608f96bn%40googlegroups.com.