如何修复android中的InputMethodManager泄漏?

时间:2017-08-14 15:17:03

标签: android android-layout memory-leaks textview android-textwatcher

我在android中的登录片段中看到来自android视图的InputMethodManager泄漏。我正在使用泄漏检测这些。有没有人以前遇到过这些问题并知道如何解决它?

这是我的泄漏信息:

In com.mymyapp.myapp2.beta.debug:2.1
* com.myapp.enterprise.registration.steps.LoginFragment has leaked:
* GC ROOT android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper.mParentInputMethodManager
* references android.view.inputmethod.InputMethodManager.mNextServedView
* references android.support.design.widget.TextInputEditText.mListeners
* references java.util.ArrayList.elementData
* references array java.lang.Object[].[1]
* references com.myapp.enterprise.registration.steps.LoginFragment$1.this$0 (anonymous implementation of android.text.TextWatcher)
* leaks com.myapp.enterprise.registration.steps.LoginFragment instance

* Retaining: 447 B.
* Reference Key: 4cc86cd2-758c-4888-9b57-67d28ff25cab
* Device: motorola motorola Moto G (4) athene_f
* Android Version: 7.0 API: 24 LeakCanary: 1.5.1 1be44b3
* Durations: watch=5235ms, gc=152ms, heap dump=2299ms, analysis=80574ms

* Details:
* Instance of android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper
|   static $classOverhead = byte[540]@1877175625 (0x6fe36d49)
|   mParentInputMethodManager = android.view.inputmethod.InputMethodManager@315489008 (0x12cdfaf0)
|   mFinished = false
|   mH = com.android.internal.view.IInputConnectionWrapper$MyHandler@314608480 (0x12c08b60)
|   mInputConnection = android.view.inputmethod.BaseInputConnection@314608192 (0x12c08a40)
|   mInputMethodId = null
|   mLock = java.lang.Object@314601304 (0x12c06f58)
|   mMainLooper = android.os.Looper@315147520 (0x12c8c500)
|   mDescriptor = java.lang.String@1871530992 (0x6f8d4bf0)
|   mObject = -1520699784
|   mOwner = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@315227656 (0x12c9fe08)
|   shadow$_klass_ = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper
|   shadow$_monitor_ = 0
* Instance of android.view.inputmethod.InputMethodManager
|   static SHOW_IMPLICIT = 1
|   static DISPATCH_NOT_HANDLED = 0
|   static $classOverhead = byte[725]@1877047225 (0x6fe177b9)
|   static RESULT_SHOWN = 2
|   static sInstance = android.view.inputmethod.InputMethodManager@315489008 (0x12cdfaf0)
|   static RESULT_HIDDEN = 3
|   static MSG_UNBIND = 3
|   static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1
|   static SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES = 2
|   static RESULT_UNCHANGED_HIDDEN = 1
|   static MSG_SET_ACTIVE = 4
|   static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9
|   static CONTROL_WINDOW_FIRST = 4
|   static DISPATCH_IN_PROGRESS = -1
|   static HIDE_NOT_ALWAYS = 2
|   static TAG = java.lang.String@1873435512 (0x6faa5b78)
|   static INPUT_METHOD_NOT_RESPONDING_TIMEOUT = 2500
|   static SHOW_FORCED = 2
|   static CONTROL_WINDOW_IS_TEXT_EDITOR = 2
|   static SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES = 1
|   static CONTROL_WINDOW_VIEW_HAS_FOCUS = 1
|   static MSG_BIND = 2
|   static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0
|   static DEBUG = false
|   static HIDE_IMPLICIT_ONLY = 1
|   static PENDING_EVENT_COUNTER = java.lang.String@1873392392 (0x6fa9b308)
|   static CONTROL_START_INITIAL = 256
|   static MSG_FLUSH_INPUT_EVENT = 7
|   static DISPATCH_HANDLED = 1
|   static MSG_SEND_INPUT_EVENT = 5
|   static SHOW_IM_PICKER_MODE_AUTO = 0
|   static MSG_DUMP = 1
|   static RESULT_UNCHANGED_SHOWN = 0
|   static MSG_TIMEOUT_INPUT_EVENT = 6
|   mActive = true
|   mBindSequence = 9
|   mClient = android.view.inputmethod.InputMethodManager$1@314607808 (0x12c088c0)
|   mCompletions = null
|   mCurChannel = android.view.InputChannel@320646608 (0x131cadd0)
|   mCurId = java.lang.String@320729664 (0x131df240)
|   mCurMethod = com.android.internal.view.IInputMethodSession$Stub$Proxy@320646592 (0x131cadc0)
|   mCurRootView = com.android.internal.policy.DecorView@319166464 (0x13061800)
|   mCurSender = null
|   mCurrentTextBoxAttribute = android.view.inputmethod.EditorInfo@315732752 (0x12d1b310)
|   mCursorAnchorInfo = null
|   mCursorCandEnd = -1
|   mCursorCandStart = -1
|   mCursorRect = android.graphics.Rect@315027712 (0x12c6f100)
|   mCursorSelEnd = 0
|   mCursorSelStart = 0
|   mDummyInputConnection = android.view.inputmethod.BaseInputConnection@314608192 (0x12c08a40)
|   mFullscreenMode = false
|   mH = android.view.inputmethod.InputMethodManager$H@314608448 (0x12c08b40)
|   mHasBeenInactive = false
|   mIInputContext = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@315227656 (0x12c9fe08)
|   mLastBindFailed = false
|   mLastSentUserActionNotificationSequenceNumber = -1
|   mMainLooper = android.os.Looper@315147520 (0x12c8c500)
|   mNextServedView = android.support.design.widget.TextInputEditText@320574464 (0x131b9400)
|   mNextUserActionNotificationSequenceNumber = 2
|   mPendingEventPool = android.util.Pools$SimplePool@314591328 (0x12c04860)
|   mPendingEvents = android.util.SparseArray@315027736 (0x12c6f118)
|   mRequestUpdateCursorAnchorInfoMonitorMode = 0
|   mServedConnecting = false
|   mServedInputConnectionWrapper = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@320700984 (0x131d8238)
|   mServedView = android.support.design.widget.TextInputEditText@320574464 (0x131b9400)
|   mService = com.android.internal.view.IInputMethodManager$Stub$Proxy@314591312 (0x12c04850)
|   mTmpCursorRect = android.graphics.Rect@315027688 (0x12c6f0e8)
|   shadow$_klass_ = android.view.inputmethod.InputMethodManager
|   shadow$_monitor_ = 0
* Instance of android.support.design.widget.TextInputEditText
|   static $classOverhead = byte[4196]@318885889 (0x1301d001)
|   mBackgroundTintHelper = android.support.v7.widget.AppCompatBackgroundHelper@320353600 (0x13183540)
|   mTextHelper = android.support.v7.widget.AppCompatTextHelperV17@320586064 (0x131bc150)
|   mAllowTransformationLengthChange = false
|   mAutoLinkMask = 0
|   mBoring = null
|   mBreakStrategy = 0
|   mBufferType = android.widget.TextView$BufferType@1876983128 (0x6fe07d58)
|   mChangeWatcher = android.widget.TextView$ChangeWatcher@320578160 (0x131ba270)
|   mCharWrapper = null
|   mCurHintTextColor = -2130706433
|   mCurTextColor = -1
|   mCurrentSpellCheckerLocaleCache = java.util.Locale@320708816 (0x131da0d0)
|   mCursorDrawableRes = 17303398
|   mDeferScroll = -1
|   mDesiredHeightAtMeasure = 136
|   mDeviceProvisionedState = 0
|   mDrawables = android.widget.TextView$Drawables@317326336 (0x12ea0400)
|   mEditableFactory = android.text.Editable$Factory@1876974048 (0x6fe059e0)
|   mEditor = android.widget.Editor@320363200 (0x13185ac0)
|   mEllipsize = null
|   mFilters = android.text.InputFilter[1]@320581488 (0x131baf70)
|   mFreezesText = false
|   mGravity = 8388627
|   mHighlightColor = 1727238656
|   mHighlightPaint = android.graphics.Paint@320566528 (0x131b7500)
|   mHighlightPath = android.graphics.Path@320715264 (0x131dba00)
|   mHighlightPathBogus = false
|   mHint = null
|   mHintBoring = null
|   mHintLayout = null
|   mHintTextColor = android.content.res.ColorStateList@315715920 (0x12d17150)
|   mHorizontallyScrolling = true
|   mHyphenationFrequency = 1
|   mIncludePad = true
|   mLastLayoutDirection = 0
|   mLastScroll = 0
|   mLayout = android.text.DynamicLayout@316962680 (0x12e47778)
|   mLinkTextColor = android.content.res.ColorStateList@315160584 (0x12c8f808)
|   mLinksClickable = true
|   mListeners = java.util.ArrayList@320590248 (0x131bd1a8)
|   mLocalesChanged = false
|   mMarquee = null
|   mMarqueeFadeMode = 0
|   mMarqueeRepeatLimit = 3
|   mMaxMode = 1
|   mMaxWidth = 2147483647
|   mMaxWidthMode = 2
|   mMaximum = 1
|   mMinMode = 1
|   mMinWidth = 0
|   mMinWidthMode = 2
|   mMinimum = 1
|   mMovement = android.text.method.ArrowKeyMovementMethod@314601176 (0x12c06ed8)
|   mOldMaxMode = 1
|   mOldMaximum = 1
|   mPreDrawListenerDetached = false
|   mPreDrawRegistered = false
|   mPreventDefaultMovement = false
|   mRestartMarquee = false
|   mSavedHintLayout = null
|   mSavedLayout = null
|   mSavedMarqueeModeLayout = null
|   mScroller = null
|   mShadowColor = 0
|   mShadowDx = 0.0
|   mShadowDy = 0.0
|   mShadowRadius = 0.0
|   mSingleLine = true
|   mSpacingAdd = 0.0
|   mSpacingMult = 1.0
|   mSpannableFactory = android.text.Spannable$Factory@1876974072 (0x6fe059f8)
|   mTempRect = android.graphics.Rect@320671576 (0x131d0f58)
|   mText = android.text.SpannableStringBuilder@316625152 (0x12df5100)
|   mTextColor = android.content.res.ColorStateList@1946482152 (0x7404f5e8)
|   mTextDir = android.text.TextDirectionHeuristics$TextDirectionHeuristicInternal@1876982208 (0x6fe079c0)
|   mTextEditSuggestionContainerLayout = 17367286
|   mTextEditSuggestionHighlightStyle = 16974923
|   mTextEditSuggestionItemLayout = 17367288
|   mTextPaint = android.text.TextPaint@317801744 (0x12f14510)
|   mTextSelectHandleLeftRes = 17303402
|   mTextSelectHandleRes = 17303404
|   mTextSelectHandleRightRes = 17303406
|   mTransformation = android.text.method.SingleLineTransformationMethod@314601392 (0x12c06fb0)
|   mTransformed = android.text.method.ReplacementTransformationMethod$SpannedReplacementCharSequence@320632600 (0x131c7718)
|   mUserSetTextScaleX = false
|   mAccessibilityCursorPosition = -1
|   mAccessibilityDelegate = null
|   mAccessibilityTraversalAfterId = -1
|   mAccessibilityTraversalBeforeId = -1
|   mAccessibilityViewId = -1
|   mAnimator = null
|   mAttachInfo = android.view.View$AttachInfo@318798336 (0x13007a00)
|   mAttributes = null
|   mBackground = android.graphics.drawable.InsetDrawable@319232872 (0x13071b68)
|   mBackgroundRenderNode = android.view.RenderNode@320725152 (0x131de0a0)
|   mBackgroundResource = 0
|   mBackgroundSizeChanged = false
|   mBackgroundTint = null
|   mBottom = 136
|   mCachingFailed = false
|   mClipBounds = null
|   mContentDescription = null
|   mContext = com.myapp.enterprise.registration.RegistrationActivity@316654784 (0x12dfc4c0)
|   mCurrentAnimation = null
|   mDrawableState = int[4]@1870821352 (0x6f8277e8)
|   mDrawingCache = null
|   mDrawingCacheBackgroundColor = 0
|   mFloatingTreeObserver = null
|   mForegroundInfo = null
|   mFrameMetricsObservers = null
|   mGhostView = null
|   mHasPerformedLongPress = false
|   mID = 2131755351
|   mIgnoreNextUpEvent = false
|   mInContextButtonPress = false
|   mInputEventConsistencyVerifier = null
|   mKeyedTags = null
|   mLabelForId = -1
|   mLastIsOpaque = false
|   mLayerPaint = null
|   mLayerType = 0
|   mLayoutInsets = null
|   mLayoutParams = android.widget.FrameLayout$LayoutParams@319233600 (0x13071e40)
|   mLeft = 0
|   mLeftPaddingDefined = false
|   mListenerInfo = null
|   mLongClickX = NaN
|   mLongClickY = NaN
|   mMatchIdPredicate = null
|   mMatchLabelForPredicate = null
|   mMeasureCache = android.util.LongSparseLongArray@320670400 (0x131d0ac0)
|   mMeasuredHeight = 136
|   mMeasuredWidth = 984
|   mMinHeight = 0
|   mMinWidth = 0
|   mNestedScrollingParent = null
|   mNextFocusDownId = -1
|   mNextFocusForwardId = -1
|   mNextFocusLeftId = -1
|   mNextFocusRightId = -1
|   mNextFocusUpId = -1
|   mOldHeightMeasureSpec = 455
|   mOldWidthMeasureSpec = 1073742808
|   mOutlineProvider = android.view.ViewOutlineProvider$1@1876974296 (0x6fe05ad8)
|   mOverScrollMode = 1
|   mOverlay = null
|   mPaddingBottom = 33
|   mPaddingLeft = 12
|   mPaddingRight = 12
|   mPaddingTop = 30
|   mParent = android.widget.FrameLayout@320573440 (0x131b9000)
|   mPendingCheckForLongPress = null
|   mPendingCheckForTap = null
|   mPerformClick = null
|   mPointerIcon = null
|   mPrivateFlags = 16943154
|   mPrivateFlags2 = 1611867688
|   mPrivateFlags3 = 4
|   mRecreateDisplayList = false
|   mRenderNode = android.view.RenderNode@319924904 (0x1311aaa8)
|   mResources = android.content.res.Resources@314613440 (0x12c09ec0)
|   mRight = 984
|   mRightPaddingDefined = false
|   mRunQueue = android.view.HandlerActionQueue@320644752 (0x131ca690)
|   mScrollCache = null
|   mScrollIndicatorDrawable = null
|   mScrollX = 0
|   mScrollY = 0
|   mSendViewScrolledAccessibilityEvent = null
|   mSendViewStateChangedAccessibilityEvent = null
|   mSendingHoverAccessibilityEvents = false
|   mStartActivityRequestWho = null
|   mStateListAnimator = null
|   mSystemUiVisibility = 0
|   mTag = null
|   mTempNestedScrollConsumed = null
|   mTop = 0
|   mTouchDelegate = null
|   mTouchSlop = 48
|   mTransformationInfo = android.view.View$TransformationInfo@320671408 (0x131d0eb0)
|   mTransientStateCount = 0
|   mTransitionName = null
|   mUnscaledDrawingCache = null
|   mUnsetPressedState = null
|   mUserPaddingBottom = 33
|   mUserPaddingEnd = -2147483648
|   mUserPaddingLeft = 12
|   mUserPaddingLeftInitial = 12
|   mUserPaddingRight = 12
|   mUserPaddingRightInitial = 12
|   mUserPaddingStart = -2147483648
|   mVerticalScrollFactor = 0.0
|   mVerticalScrollbarPosition = 0
|   mViewFlags = 405028865
|   mWindowAttachCount = 1
|   shadow$_klass_ = android.support.design.widget.TextInputEditText
|   shadow$_monitor_ = 0
* Instance of java.util.ArrayList
|   static $classOverhead = byte[460]@1870958273 (0x6f848ec1)
|   static EMPTY_ELEMENTDATA = java.lang.Object[0]@1870221960 (0x6f795288)
|   static DEFAULT_CAPACITY = 10
|   static MAX_ARRAY_SIZE = 2147483639
|   static serialVersionUID = 8683452581122892189
|   elementData = java.lang.Object[10]@319233656 (0x13071e78)
|   size = 2
|   modCount = 2
|   shadow$_klass_ = java.util.ArrayList
|   shadow$_monitor_ = 0
* Array of java.lang.Object[]
|   [0] = android.support.design.widget.TextInputLayout$1@320578240 (0x131ba2c0)
|   [1] = com.myapp.enterprise.registration.steps.LoginFragment$1@319186144 (0x130664e0)
|   [2] = null
|   [3] = null
|   [4] = null
|   [5] = null
|   [6] = null
|   [7] = null
|   [8] = null
|   [9] = null
* Instance of com.myapp.enterprise.registration.steps.LoginFragment$1
|   static $change = null
|   static $classOverhead = byte[328]@317118193 (0x12e6d6f1)
|   static serialVersionUID = 0
|   this$0 = com.myapp.enterprise.registration.steps.LoginFragment@317871008 (0x12f253a0)
|   shadow$_klass_ = com.myapp.enterprise.registration.steps.LoginFragment$1
|   shadow$_monitor_ = 0
* Instance of com.myapp.enterprise.registration.steps.LoginFragment
|   static $classOverhead = byte[964]@316739585 (0x12e11001)
|   static MIN_PASSWORD_LENGTH = 8
|   static $change = null
|   static MAX_PASSWORD_LENGTH = 26
|   static serialVersionUID = 0
|   emailOK = false
|   errorTextView = android.support.v7.widget.AppCompatTextView@320600064 (0x131bf800)
|   forgotPasswordButton = android.support.v7.widget.AppCompatButton@320603136 (0x131c0400)
|   loginRegisterButton = android.support.v7.widget.AppCompatButton@320601088 (0x131bfc00)
|   mPasswordWatcher = com.myapp.enterprise.registration.steps.LoginFragment$2@319186160 (0x130664f0)
|   mUsernameWatcher = com.myapp.enterprise.registration.steps.LoginFragment$1@319186144 (0x130664e0)
|   passwordEditText = android.support.design.widget.TextInputEditText@320599040 (0x131bf400)
|   passwordOK = false
|   usernameEditText = android.support.design.widget.TextInputEditText@320574464 (0x131b9400)
|   usernameLayout = android.support.design.widget.TextInputLayout@320572416 (0x131b8c00)
|   registrationInterface = com.myapp.enterprise.registration.RegistrationActivity@316654784 (0x12dfc4c0)
|   mAdded = true
|   mAnimationInfo = null
|   mArguments = null
|   mBackStackNesting = 0
|   mCalled = true
|   mCheckedForLoaderManager = true
|   mChildFragmentManager = android.support.v4.app.FragmentManagerImpl@317804096 (0x12f14e40)
|   mChildNonConfig = null
|   mContainer = android.support.v7.widget.ContentFrameLayout@319220736 (0x1306ec00)
|   mContainerId = 16908290
|   mDeferStart = false
|   mDetached = false
|   mFragmentId = 16908290
|   mFragmentManager = android.support.v4.app.FragmentManagerImpl@317317632 (0x12e9e200)
|   mFromLayout = false
|   mHasMenu = false
|   mHidden = false
|   mHiddenChanged = false
|   mHost = android.support.v4.app.FragmentActivity$HostCallbacks@319197776 (0x13069250)
|   mInLayout = false
|   mIndex = 0
|   mInnerView = android.widget.LinearLayout@320559104 (0x131b5800)
|   mIsNewlyAdded = false
|   mLoaderManager = null
|   mLoadersStarted = true
|   mMenuVisible = true
|   mParentFragment = null
|   mPostponedAlpha = 0.0
|   mRemoving = false
|   mRestored = true
|   mRetainInstance = false
|   mRetaining = false
|   mSavedFragmentState = null
|   mSavedViewState = null
|   mState = 5
|   mTag = java.lang.String@317199808 (0x12e815c0)
|   mTarget = null
|   mTargetIndex = -1
|   mTargetRequestCode = 0
|   mUserVisibleHint = true
|   mView = android.widget.LinearLayout@320559104 (0x131b5800)
|   mWho = java.lang.String@319178112 (0x13064580)
|   shadow$_klass_ = com.myapp.enterprise.registration.steps.LoginFragment
|   shadow$_monitor_ = 0
* Excluded Refs:
| Field: android.view.textservice.SpellCheckerSession$1.this$0
| Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
| Thread:FinalizerWatchdogDaemon (always)
| Thread:main (always)
| Thread:LeakCanary-Heap-Dump (always)
| Class:java.lang.ref.WeakReference (always)
| Class:java.lang.ref.SoftReference (always)
| Class:java.lang.ref.PhantomReference (always)
| Class:java.lang.ref.Finalizer (always)
| Class:java.lang.ref.FinalizerReference (always)

我没有使用textwatcher的任何匿名引用。我基本上将它分开以避免任何泄漏。对于一些textview,我仍然看到这个漏洞吗?不知道如何解决这个问题?任何人有任何线索或以前经历过这个?

0 个答案:

没有答案