Describe the bug
When injecting a ViewModel(with parameters) with KOIN, an Activity is being leaked through KoinFactory->ViewModel->Fragment->NavHostFragment->NavController->Activity.
To Reproduce
Expected behavior
No memory leak.
Koin project used and used version (please complete the following information):
koin-core, -android, -android-architecture 0.9.3
androidx.Navigation - 1.0.0-alpha02
Additional context'
LeakCanary report:
https://gist.github.com/trobertsca/c56cb2a87be67b4ad1e54f5f54a44f4c
I'm not 100% sure this is due to KOIN, but my google-fu is failing me.
Can you provide your code sample? Memory leak can also depend on your usage of Koin.
Here's a gist with what I believe are all the relevant files: https://gist.github.com/trobertsca/dd1acd78a0d3e9636893c4258933b1a5
If you need anything more just let me know. (And excuse the code, I'm somewhat new to kotlin+android :) )
Does one of your parameters reference a ViewModel?
No, the only parameters passed with koin would be a Context for the RoomDatabase, the Dao for the Repository, the Repository for ViewModels, and an int for a ViewModel.
@trobertsca could you help me save time, by making a real android project and share it as a public github project?
It will help investigate ;)
Kind of "good news". I reproduced a memory leak with ViewModel & injection parameters :/
I can investigate...
it's fixed. Just need time to release it. Available inkoin-android-viewmodel version 1.0.0-alpha-28
I'm releasing it
Awesome! You rock :)
Most helpful comment
Awesome! You rock :)