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

gotoOla

11/29/2018, 1:30 PM
Are there any known memory gotchas that were introduced with the 1.0 release and switch to structured concurrency (where launch and async are extensions on a coroutinescope?) The reason why I am asking is that we have had a service running for quite a long while with kotlin 1.2.61 and when we tried to bump it to kotlin 1.3 we are continously increasing in memory until we eventually crash
The only “big” functionality change we did was going over the code and we are now using coroutineScope {} instead of launching/asyncing from the GlobalScope
o

oshai

11/29/2018, 2:44 PM
did you checked what objects are causing the OutOfMemory?
k

kevinherron

11/29/2018, 5:27 PM
maybe you're using
GlobalScope.launch
and
GlobalScope.async
all over the place now to get it working and it turns out you're actually leaking those coroutines
g

gildor

11/30/2018, 1:20 AM
now using coroutineScope {} instead of launching/asyncing from the GlobalScope
Hmm, but those are pretty different, how you could replace global coroutines with local
coroutineScope
function? coroutineScope suspends untill all child coroutines are finished, maybe you just have many leaked coroutines?
g

gotoOla

11/30/2018, 8:46 AM
@kevinherron No we are not @gildor we don’t do much of fire and forget in out service. In all cases we do async but then await or launch and join so I understand what you are meaning with the different behavior but that shouldn’t be the case
g

gildor

11/30/2018, 9:06 AM
I would first profile what is going on and where is leak, most probably there is a some leak caused by semantic changes during migration to structured concurrency
g

gotoOla

11/30/2018, 9:16 AM
Cool, that will be our next step! Is VisualVM enough or are there any options that work better with kotlin? Thanks for the feedback @gildor and everybody else
g

gildor

11/30/2018, 9:41 AM
VisualVM should be enough
👍 1
4 Views