https://kotlinlang.org logo
#coroutines
Title
# coroutines
u

ursus

05/20/2021, 2:41 AM
Is it leaky if I never cancel a coroutine scope, but all it's jobs are finished?
e

ephemient

05/20/2021, 3:29 AM
1. if you have a reference to the scope, it won't be garbage collected 2. if you don't have a reference to the scope (or to something related, such as a job) then I believe you are at risk of the jobs getting garbage collected before running to completion
u

ursus

05/20/2021, 11:38 AM
its sortof a 3. its a broadcast receiver, system instantiates it, i'd create scope as a private val. then system calls onReceive, i run suspend funs in the private scope after 10s system kills the receiver instance, however there is no onDestroy callback for me to cancel the scope its only db queries so 10s will be more than enough and 99.99% the jobs will complete is that a leak after 10s?
2 Views