Do I need to keep a strong reference to a continua...
# coroutines
a
Do I need to keep a strong reference to a continuation given to me in
suspendCancellableCoroutine
? I need to work around a memory leak and I was planning on doing that by keeping a weak ref to the continuation
d
You can but you must be able to call
resume
on it at some point.
a
Well, I can’t guarantee that either which is why I also have a
withTimeout
around it
l
You are likely to get your coroutine garbage collected while suspended if you use a weak reference on it
a
Hmm, so I need to keep a strong reference?
b
You should keep a strong reference to things you don’t want garbage collected.
1
a
I know that… but I was hoping that the parent job would keep a strong ref so I didn’t have to
Actually I can’t find any reference to a job only keeping a weak ref to child jobs