On Thu, Mar 2, 2017 at 1:01 AM, Yota Toyama <ravi...@gmail.com> wrote: > > I'm trying to understand argument liveness in Go 1.8. > As preparation for it, I wrote 2 programs which iterate over infinite lists. > At first, I thought both can be run forever without any memory leak. > However, the result was that one could and the other couldn't. > > Their main difference is the way to iterate lists. > > l := *NewList(42, nil) > > for { > l = *l.Rest() // Cause no memory leak :) > } > > vs > > l := NewList(42, nil) > > for { > l = l.Rest() // Cause memory leak!!! > } > > The repository is here. > I wanna understand why the latter causes memory leak and what is going on in > my programs at low level. > Any ideas?
You can use the -live option with the compiler to see debugging output about the compiler's liveness analysis. For example, `go tool compile -live foo.go`. I don't think the answer to your question is going to be very interesting. I suspect that it will have something to do with the details of how the program is compiled. I expect that the answer will change in different releases and with different compilers. 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. For more options, visit https://groups.google.com/d/optout.