Am I correct in thinking that ```launch { single...
# coroutines
d
Am I correct in thinking that
Copy code
launch {
  singletonReceiveChannel.consumeEach { printLine(it) }
}
will produce a memory leak due to
consumeEach
never getting canceled, even if `launch`'s CoroutineScope ends?
z
If the launch's scope or job is cancelled, consumeEach should be cancelled as well.
d
Oh really? That's perfect, then
I was thinking that since
consumeEach
stays suspended, it wouldn't be canceled
b
suspend
generally means that function becomes part of the caller's scope/structured concurrency (in this case, the
launch
's scope)
🙏 1
z
Cancellation primarily means suspended coroutines are cancelled. Running code can’t actually be cancelled unless it cooperatively checks for cancellation.
1
d
ahh, that's what i was hung up on then