I finally took a look at the assembly, and unsurprisingly, a lot of pointers are being kept in registers. I'm not sure how registers interact with the GC, but I figured the memory might be free-able once function returns. Sure enough: https://play.golang.org/p/zpmVYSyKvX.
Thanks for the help in digging into this, Ian! This was really bugging me. - Drew On Thursday, December 22, 2016 at 11:17:11 AM UTC-5, dr...@pendo.io wrote: > > Hi all, > > I was just toying around with pointers to slice elements, and I ended up > with this Go program: https://play.golang.org/p/D6e2SHEW1f. By the end of > the program, all references to memory in the main function are dropped, but > memory isn't freed after a call to runtime.GC(). This happens both in the > Go Playground and on my local machine (though the latter is running Go 1.6). > > Is it just that runtime.GC() is not triggering a full GC and a later run > would clear the memory? Any insight here would be appreciated, as I'm > really curious now. Also, this isn't just a toy problem; it reflects some > actual code I'm working on. > > Thanks, > - Drew > -- 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.