ReactiveCircus/FlowBinding

LeakCanary shows leaks on standard usage

jakoss opened this issue · 2 comments

Hi,

LeakCanary just showed me this:
image

It seems like the root of the leak is the lifecycle registry:
image

Do you an idea why this is happening?

The code that caused that is:

binding.goBtn.clicks()
        .onEach { navigateToAnotherFragment() }
        .launchIn(lifecycleScope)

In a Fragment you should use viewLifecycleOwner.lifecycleScope instead of lifecycleScope. That's the only issue as far as I can see.

BTW the full leakcanary stacktrace is also available in logcat so it'd be easier to share that instead of screenshots 😄 .

Please let me know if that fixes the leak for you.

Wow, didn't know that viewLifecycleOwner has it's own coroutine scope. I learned something new, that's always good.

I can confirm that this indeed solves the issue