What happens when a channel goes out of scope

The data in the channel do not implicitly reference the channel, so the channel should be collected independent of its contents, unless, of course the data are structs that do reference the channel. In that case, mutual references are not a problem for garbage collection. However, the data cannot be collected if an uncollected channel still references them.

1 Like