square/flow

InternalLifecycleIntegration memory leak on P emulator

edenman opened this issue · 1 comments

In co.recharge.consumer.debug:1.15.2:96.
* flow.InternalLifecycleIntegration has leaked:
* static FontsContract.sContext
* ↳ DebugConsumerApp.injectedAuthenticatedStuff
* ↳ ConsumerApp$InjectedAuthenticatedStuff.onSignedInHelper
* ↳ OnSignedInHelper.signInHooks
* ↳ array OnSignedIn[].[4]
* ↳ PlaceDirections.placeIDToDirectionsRelays
* ↳ LinkedHashMap.tail
* ↳ LinkedHashMap$LinkedHashMapEntry.value
* ↳ BehaviorRelay.state
* ↳ RelaySubscriptionManager.value
* ↳ RelaySubscriptionManager$State.observers
* ↳ array RelaySubscriptionManager$RelayObserver[].[0]
* ↳ RelaySubscriptionManager$RelayObserver.actual
* ↳ OperatorObserveOn$ObserveOnSubscriber.child
* ↳ OnSubscribeOnAssembly$OnAssemblySubscriber.actual
* ↳ SafeSubscriber.actual
* ↳ ActionSubscriber.onNext
* ↳ WalkingTimeView$setPlace$1.this$0 (anonymous implementation of rx.functions.Action1)
* ↳ WalkingTimeView.!(mContext)!
* ↳ FlowContextWrapper.!(mBase)!
* ↳ MainActivity.mFragments
* ↳ FragmentController.mHost
* ↳ Activity$HostCallbacks.mFragmentManager
* ↳ FragmentManagerImpl.mAdded
* ↳ ArrayList.elementData
* ↳ array Object[].[0]
* ↳ InternalLifecycleIntegration

A fun thing I learned today is that Flow uses Fragments for some reason? I'm looking at the InternalLifecycleIntegration code and I'm pretty much baffled by what's going on. Looks like it attaches a fragment to the Activity in onCreate, but then somehow FragmentManager is keeping a reference to it even after the activity has been destroyed?

LeakCanary 1.6.2, fwiw

InternalLifecycleIntegration is a retained fragment, yes, but you're leaking the observers of * ↳ PlaceDirections.placeIDToDirectionsRelays yourself.

You need to unsubscribe your lambdas. Use composite disposables.