Original post on stackoverflow:
https://stackoverflow.com/questions/73985794/for-range-loop-variable-passing-by-reference-to-go-routine-causes-memory-leak Code for reproducing the problem: https://go.dev/play/p/7Xzx1Aauzhh go version go1.19 darwin/amd64 go tool pprof http://localhost:6060/debug/pprof/heap func1 is leaking https://i.stack.imgur.com/LTXHn.png Is there any reason for this leaking? Thank you for any input -- 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/4584d6b1-5120-4f0d-8887-4316a05e4086n%40googlegroups.com.