-1

After updating leakCanary to 1.6.2 got leaks when replace + addToBackstack used.

How can I handle it?

android.support.constraint.ConstraintLayout has leaked:
Toast$TN.mNextView
    LinearLayout.mContext
    PinSetCodeActivity.fragmentProcessor
    OverlayFragmentProcessor.fragmentManager
    FragmentManagerImpl.mActive
    SparseArray.mValues
    array Object[].[1]
    PinInputFragment.!(mSavedViewState)!
    SparseArray.!(mValues)!
    array Object[].!([4])!
    TextView$SavedState.!(text)!
    SpannableStringBuilder.!(mSpans)!
    array Object[].!([1])!
    PasswordTransformationMethod$Visible.!(mText)!
    SpannableStringBuilder.!(mSpans)!
    array Object[].!([0])!
    TextView$ChangeWatcher.!(this$0)!
    LinearLayout.mParent
    ConstraintLayout
Reference Key: 83b4e2f0-f09c-40dd-a639-2d27e91c9ea3
Device: samsung samsung SM-G950F dreamltexx
Android Version: 8.0.0 API: 26 LeakCanary: 1.6.2 0ebc1fc
Durations: watch=5202ms, gc=232ms, heap dump=1603ms, analysis=14172ms
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
Serhii Hrabas
  • 401
  • 1
  • 5
  • 12

1 Answers1

1

it's kinda hard to guess what's causing the leak without seeing related source code, but TextView$ChangeWatcher.!(this$0)! suggests, that you set a TextWatcher in the Fragment beeing replaced. If you don't remove this watcher in the fragments "onDestroyView" method it will keep a hard reference to the view it's attached to. This will prevent the garbage collection and leads to the leak suggested by LeakCanary.

SebRut
  • 585
  • 4
  • 22