Kotlin Multiplatform: Memory management old and new way
summary
Explains concrete failures and fixes when sharing objects across threads in Kotlin Multiplatform: coroutines throw invalid-mutability or context-bound exceptions when switching between Dispatchers.default and main unless objects are made thread-safe; examples use freeze/unfreeze and Worker.start with futures and callbacks to show the invalid mutability exception and the atomic reference workaround; shows detached graph and background Worker use and how to return results to main; describes migration to new memory model (K/N 1.6) where freezing is removed and default dispatchers bind to iOS global queue, but notes library support, Xcode 12.5, and special coroutine branches are required.
AI-written summary · about
chapters (42)
- 0:00Introduction
- 0:35Outline
- 1:58Common model
- 3:05Expect actual
- 8:17Android
- 9:10GVM
- 9:51Exception
- 11:11Magic command
- 12:26Why specify freeze
- 13:03Old solution
- 13:26Threading
- 15:18Native mechanism
- 16:28Sample code
- 16:54Android implementation
- 18:02Background worker
- 19:01void
- 19:12callback
- 20:20unfrozen
- 22:38fix code
- 23:46attached object craft
- 25:56channels flows
- 28:49iOS flow collector
- 29:45Kotlin flow wrapper
- 30:13Kotlin flow from iOS
- 30:39New memory management model
- 33:47Kotlin migration
- 34:38Transformation
- 35:26Data collection
- 35:48Default dispatchers
- 37:18UI dispatcher
- 38:03Single thread context
- 38:43Stable version of libraries
- 40:07Summary
- 42:01Questions
- 43:00Kotlin Multiplatform
- 44:51Atomic references
- 46:35Exception handling
- 47:52Using empty versions
- 49:40Should you learn Kotlin
- 50:15Using Kotlin with your native applications
- 52:35GitHub Tool
- 53:10Memory allocation
related talks
42mKotlin Multiplatform multithreading old and new way
44mKotlin/Native Concurrency for Mobile Multiplatform
39mKotlin Native Concurrency Explained
41mCoroutines for Kotlin Multiplatform in practise
39mKotlin Native Concurrency Explained
36mKotlin Multiplatform at five years
35mKotlin Coroutine Mechanisms
46mKotlin/Native Concurrency Model
