How concerned should I be because of this? <https:...
# coroutines
a
o
FWIW I've never run into memory problems with coroutines -- not that it can't happen, but it's not common. Perhaps for long-running (>24h?) programs it should be very concerning, but for developing it's never been an issue.
g
You should be concerned if you use coroutines like this. Don't use global scope in lifecyle aware components like activity.
💯 5
g
What about the last comment in the original kotlin thread? Does he has a point tho, if he is right in his findings about Bitmap not being collected?
g
Would be good to see original heap dump, I see that bitmap reference by GC and prepared to clean, would be good to run GC manually and see, will it be collected or not, same, Im pretty sure that if you check coroutine object it also referened only by cleaner
a
Thanks.
I'm not working on Android though
g
I don't think that it somehow Android specific, not only Android need lifecyle management of async jobs
s
This has nothing to do with global scope if I understand correctly. The variable goes out of scope and should be freed. I don't know if this is profiled correctly or not. Assuming it was done correctly I'd be concerned and would deliberately set the variable referencing the bitmap to null and see if that helps
g
Yes, your are right Tim, many (including me) triggered by globalscope, but this is not real issue, I believe there is no issue in this case, just wrong interpretation of heap dump, you can see that bitmap already reference by GC and prepared to clean Issue mentioned on Kotlin forum about early reference cleanup also not related to this particular case, because this is not the case of original issue when you have some object that used already and not required for other states of coroutine, so may be cleanup before coroutines is finished
s
You are correct. I tried to reproduce it (not on android though). An explicit GC invokation in VisualVM will free all the memory. 👍 I would've been surprised if it wasn't the case. edit: Which I would've known if I read the linked discussion on discuss.kotlinlang.. 😄