mediumConceptScenarioMidSenior
What does structured concurrency actually give you in Kotlin coroutines, and how does a coroutine scope leak happen despite it?
4 min readUpdated 2026-08-15
Answer
Short answer
Structured concurrency ties a coroutine's lifetime to a CoroutineScope so cancellation propagates automatically, but a leak still happens when a coroutine is launched in a scope that outlives the component that should own it, such as GlobalScope or a manually retained scope nobody cancels.
Was this answer helpful?
Likely follow-ups
- What actually happens inside a coroutine when its containing scope is cancelled mid-suspension?
- Why does launching a coroutine from a Composable directly, instead of through a LaunchedEffect, tend to cause leaks?
- How would you make a long-running coroutine cooperative with cancellation if it wraps a blocking call?
- What is the difference between SupervisorJob and a regular Job in how a child failure propagates?
Related questions
- How do you architect and implement Dynamic Feature Modules in an Android application to reduce initial download size and deliver features on demand?hardAlso on android and kotlin3 min
- How do you leverage WorkManager to guarantee execution, handle conflict resolution, and optimise battery usage in an offline-first Android application requiring bidirectional synchronisation?hardAlso on android and kotlin3 min
- A deep link opens the right screen when the app is in the background and the wrong one when the app was killed. How do you test for that?mediumAlso on android5 min
- How do you choose which devices to test on, and what will an emulator never tell you?mediumAlso on android5 min