Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native-mt] Leaks of objects crossing a thread boundary on iOS #2341

Closed
EuV opened this issue Oct 27, 2020 · 1 comment
Closed

[native-mt] Leaks of objects crossing a thread boundary on iOS #2341

EuV opened this issue Oct 27, 2020 · 1 comment
Labels

Comments

@EuV
Copy link

EuV commented Oct 27, 2020

Kotlin: 1.4.10
Coroutines: 1.3.9-native-mt-2

MainScope().launch {
    withContext(Dispatchers.Default) { // Leaks on iOS Simulator
    // withContext(Dispatchers.Main) { // Doesn't leak on iOS Simulator if GC.collect() is called
        mutableListOf<Int>().apply {
            repeat(3_000_000) {
                this += it
            }
        }
    }
    GC.collect()
}
MainScope().launch(Dispatchers.Default) {
    withContext(Dispatchers.Main) {
        // Also leaks
    }
}
MainScope().launch(Dispatchers.Default) {
    withContext(Dispatchers.Default) {
        // Does not
    }
}
@mvicsokolova
Copy link
Contributor

Most probably, leaks in these scenarios were caused by the leaking Worker created by DefaultDispatcher (see #2491). After introducing public shutdown method to DefaultDispatcher to request termination on the leaking worker (#2652), I could not reproduce any object leaks.

@qwwdfsad qwwdfsad closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants