What closing a kotlinx.coroutines channel does
coroutine, kotlin, kotlin-coroutines
Solution
Closing a channel conceptually works by sending a special "close token" over this channel. You close a channel when you have a finite sequence of elements to be processed by consumers and you must signal to the consumers that this sequence is over. You don't have to close a channel otherwise.
Channels are not tied to any native resource and they don't have to be closed to release their memory. Simply dropping all the references to a channel is fine. GC will come to do clean it up.
Problem
What closing a kotlinx.coroutines channel using channel.close() does and what the negative effect of not manually closing channels would be? If I don't manually close a channel will there be some unnecessary processing? Will there be a reference to the channel somewhere that prevents it from being GCd? Or does the close function just exist as a way of informing potential users of the channel that it can no longer be used. (Question reposted from Kotlin forum https://discuss.kotlinlang.org/t/closing-coroutine-channels/2549)