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

Memory leak with new memory model and withTimeout #3351

Closed
qwwdfsad opened this issue Jun 28, 2022 · 2 comments
Closed

Memory leak with new memory model and withTimeout #3351

qwwdfsad opened this issue Jun 28, 2022 · 2 comments

Comments

@qwwdfsad
Copy link
Member

See https://youtrack.jetbrains.com/issue/KTOR-4298 for details.

The root cause is our dispatcher implementation:


override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle {
    // No API to cancel on timeout
    worker.executeAfter(timeMillis.toMicrosSafe()) { block.run() }
    return NonDisposableHandle
}

Yet it can be workarounded by carefully replacing lambda with something holding an atomic reference to a block so it can be nulled out

pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
…n#3353)

* Reduce reachable references of disposed invokeOnTimeout handle

Fixes Kotlin#3351
Syrou added a commit to Syrou/ktor that referenced this issue Sep 30, 2022
Should hopefully address memory leaks fixed as of Kotlin/kotlinx.coroutines#3351
e5l pushed a commit to ktorio/ktor that referenced this issue Oct 4, 2022
Should hopefully address memory leaks fixed as of Kotlin/kotlinx.coroutines#3351
@alexvas
Copy link

alexvas commented Oct 5, 2022

@qwwdfsad, would you please publish 1.6.4-native-mt library version to Maven Central then?

@qwwdfsad
Copy link
Member Author

qwwdfsad commented Oct 5, 2022

The issues and the fix are related to regular versions of coroutine, the fix is not applicable for -native-mt versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants