Fork me on GitHub

Is there any information anywhere on when go loops and the like get garbage collected? A lot of tutorials create never-ending loops and I wonder where the references to them are stored. Do they belong to the channel and get GCed when the channels goes away? Are we responsible for detecting the closing of the channel and ending the loop?


@ska: go blocks are attached to whatever channel they are currently "parked" on. When the channel is eligible for GC, so is the go block. In general, it is a good idea to have a termination condition in a go loop that stops when the channel is closed.


There is no global registry of go blocks.