Fork me on GitHub
#core-async
<
2018-12-06
>
tianshu08:12:35

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

mccraigmccraig09:12:47

@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 <!)

tianshu09:12:52

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.

tianshu09:12:22

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

gordon15:12:45

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