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

addamsson

02/15/2019, 11:08 PM
o

octylFractal

02/15/2019, 11:47 PM
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

gildor

02/16/2019, 1:03 AM
You should be concerned if you use coroutines like this. Don't use global scope in lifecyle aware components like activity.
💯 5
g

ghedeon

02/16/2019, 1:13 AM
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

gildor

02/16/2019, 2:08 AM
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

addamsson

02/16/2019, 9:38 AM
Thanks.
I'm not working on Android though
g

gildor

02/16/2019, 10:08 AM
I don't think that it somehow Android specific, not only Android need lifecyle management of async jobs
s

SiebelsTim

02/16/2019, 1:28 PM
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

gildor

02/16/2019, 5:38 PM
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

SiebelsTim

02/16/2019, 10:00 PM
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.. 😄
2 Views