Fork me on GitHub

If I have a (a/go (while true (a/<! ch))), if ch can be gc collected, this go block will be no further cost?


@doglooksgood ch can't be collected - the go block has a reference to it - you should let the go block terminate when ch is closed (and thus returns the special value nil from <!)


I was trying to monitor what will happen if I create a huge amount of go block, but it seems won't cost much mem.


So it seems I don't have to close channel every time.


Right, there's no need to close a channel at all - channels (like anything else) will be garbage collected eventually when nobody holds a reference to them anymore. Whether or not you should close a channel depends on your program's needs