-
Notifications
You must be signed in to change notification settings - Fork 6
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 in LifecycleCoroutineScopeStore #136
Milestone
Comments
RBusarow
added a commit
that referenced
this issue
Jul 3, 2020
* - automatically cancel LifecycleCoroutineScope when lifecycle reaches DESTROYED (fixes #135) - automatically remove lifecycleScope extension property from cache when lifecycle reaches DESTROYED (fixes #136) * dispatch-internal-test-android module * update lifecycle handling * update lifecycle handling * update lifecycle handling * convert LifecycleScopeExtensionTest from Kotest to JUnit5 to fix some weird recursive behavior * convert LifecycleScopeExtensionTest from Kotest to JUnit5 to fix some weird recursive behavior * remove workspace.xml backup which shouldn't have been added to git
RBusarow
added a commit
that referenced
this issue
Nov 1, 2020
* update version to 1.0.0-beta04 (#137) * Kotest 4.1.0 (#138) * update Kotest to 4.1.0 * update Kotest to 4.1.0 * update Kotest to 4.1.0 * update Kotest to 4.1.0 * Revert "update Kotest to 4.1.0" This reverts commit 833c838 * fix version parsing in DocsTasks * add `release/*` matcher to ci.yml * dispatch-internal-test-android module (#139) * add hermit dependency (#140) * add hermit dependency * add Hermit to the dependency matchers in DocsTasks * Lifecycle coroutine scope leak fixes (#141) * - automatically cancel LifecycleCoroutineScope when lifecycle reaches DESTROYED (fixes #135) - automatically remove lifecycleScope extension property from cache when lifecycle reaches DESTROYED (fixes #136) * dispatch-internal-test-android module * update lifecycle handling * update lifecycle handling * update lifecycle handling * convert LifecycleScopeExtensionTest from Kotest to JUnit5 to fix some weird recursive behavior * convert LifecycleScopeExtensionTest from Kotest to JUnit5 to fix some weird recursive behavior * remove workspace.xml backup which shouldn't have been added to git * update docs from main branch * update change log (#142) * Change LifecycleCoroutineScope argument to a CoroutineContext, add LifecycleCoroutineScopeFactory (#145) * change LifecycleCoroutineScope argument to CoroutineContext * MainImmediateProvidedContext -> MainImmediateContext * MainImmediateProvidedContext -> MainImmediateContext * update docs * MainImmediateProvidedContext -> MainImmediateContext * Misc cleanup (#146) * LifecycleScopeFactory README example cleanup * remove duplicate dependency declarations in android-lifecycle gradle config * android-lifecycle sample annotation consolidation * lifecycleScope extension sample rename * MainImmediateCoroutineScope factory function formatting * update docs * - remove tabs (#147) - consolidate capitalization for modules and kdoc - add lifecycle-extensions - dtekt -> detekt * update Detekt to 1.10.0 (#148) * update Knit to 0.1.4 (#149) * coroutines 1.3.7 -> 1.3.8 (#150) * Detekt cleanup (#151) * Detekt cleanup * add detekt to CI, remove Lint * add dependency graph generator task * DefaultDispatcherProvider (#153) * add DefaultDispatcherProvider singleton holder (fixes #152) * update docs for DefaultDispatcherProvider * add resolution strategies for coroutines and dispatch (#155) * cleanup of LifecycleCoroutineScope samples (#156) * add ViewLifecycleCoroutineScope (#158) * add ViewLifecycleCoroutineScope * add ViewLifecycleCoroutineScope docs * Lifecycle coroutine scope context parameter (#160) * Add a CoroutineContext parameter to the Lifecycle launch and suspend functions * add tests * update docs * update gradle to 6.6.1 (#163) * dependency updates (#164) - Kotlin 1.4.10 - coroutines 1.3.9 - Kotest 4.2.5 * sortDependencies task (#165) * add and apply the sortDependencies task * Update build.gradle.kts * disable Jetifier (#166) * update Robolectric to 4.4 * update Detekt to 1.14.1 (#168) * Add the Dependency Analysis Android Gradle Plugin (#169) * add the Dependency Analysis Plugin and apply its suggestions * merge in the Detekt update * restore the :dispatch:core dependency in :dispatch-android-viewmodel * merge documentation/site changes from main branch * add gradle doctor plugin (#171) * add gradle enterprise plugin (#172) * add task tree plugin (#173) * junit test modules README cleanup * update Kotest to 4.3.0 (#174) * update to Gradle 6.7 and enable file system watching (#175) * update androidx versions (#177) * update kotlin plugin applications (#176) * make testProvided's receiver a TestProvidedCoroutineScope (#180) * update JUnit5 to 5.7.0 (#178) * use currentCoroutineContext to resolve context inside a Flow (#182) * update coroutines to 1.4.0 (#183) * update Detekt to 1.4.2 https://github.com/detekt/detekt/releases/tag/v1.14.2 (#184) * dependency updates (#185) * DispatchLifecycleScope & DispatchViewModel (#186) * rename LifecycleCoroutineScope to dispatchLifecycleScope.kt * CoroutineViewModel -> DispatchViewModel * CoroutineViewModel -> DispatchViewModel * CoroutineViewModel -> DispatchViewModel * remove docs/api from git * update changelog for 1.0.0-beta05 * set min and target jvm to 8 (#187) * add KDocs for deprecations
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, loved finding your library! I was just contemplating writing something like it until I came across it and it seemed to match perfectly with what I was looking for. I did however come across a few issues that I wanted to flag to see if they're on your radar - notably with
LifecycleCoroutineScopeStore
.Each access of
LifecycleOwner.lifecycleScope
for a distinctLifecycle
(any individual instance of aFragment
,Activity
, etc) results in an insertion tomap
which is never removed, leaking both theLifecycle
key and theLifecycleCoroutineScope
value.A separate issue is that
LifecycleCoroutineScopeStore
is not thread-safe, because the "get or put" logic as implemented is not atomic. Multiple concurrent invocations ofget
may return separate instances ofLifecycleCoroutineScope
, but only one of them will get stored inmap
. A possible fix would be to use Kotlin'sConcurrentMap.getOrPut
or the built-incomputeIfAbsent
.The text was updated successfully, but these errors were encountered: