Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用LeakCanary 1.3.1-SNAPSHOT. 我发现有关ViewTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码: private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener; @Override protected void 我正在使用LeakCanary 1.3.1-SNAPSHOT.
我发现有关VIEwTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码:

private VIEwTreeObserver.OnScrollChangedListener scrollVIEwchangelistener;  @OverrIDe protected voID onFinishInflate() {      super.onFinishInflate();      ButterKnife.inject(this);      scrollVIEwchangelistener = new VIEwTreeObserver.OnScrollChangedListener() {      @OverrIDe public voID onScrollChanged() {        EventDetailsVIEw.this.onScrollChanged(scrollVIEw.getScrollY());      }    };      scrollVIEw.getVIEwTreeObserver()        .addOnScrollChangedListener(scrollVIEwchangelistener);  }  @OverrIDe public voID onDetachedFromWindow() {      super.onDetachedFromWindow();      scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);  }

然而,LeakCanary仍然将其报告为泄漏,任何想法为什么?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:* GC ROOT androID.vIEw.inputmethod.inputMethodManager.this
@OverrIDe public voID onDetachedFromWindow() {    scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);    super.onDetachedFromWindow();}
(anonymous class extends com.androID.internal.vIEw.IinputMethodClIEnt$Stub)* references androID.vIEw.inputmethod.inputMethodManager.mCurRootVIEw* references com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.mAttachInfo* references androID.vIEw.VIEw$AttachInfo.mTreeObserver* references androID.vIEw.VIEwTreeObserver.mOnScrollChangedListeners* references androID.vIEw.VIEwTreeObserver$copyOnWriteArray.mData* references java.util.ArrayList.array* references array java.lang.Object[].[0]* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.this[+++] (anonymous class implements androID.vIEw.VIEwTreeObserver$OnScrollChangedListener)* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.presenter* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c* Device: LGE Google Nexus 5 hammerhead* AndroID Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT* Durations: watch=5032ms,gc=165ms,heap dump=2932ms,analysis=29907ms* Details:* Instance of androID.vIEw.inputmethod.inputMethodManager| this[+++] = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mDescriptor = java.lang.String [ID=0x6f5e3f38]| mObject = -1601862176| mOwner = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]* Instance of androID.vIEw.inputmethod.inputMethodManager| static $staticOverhead = byte[] [ID=0x6fe25d29;length=240;size=256]| static CONTRol_START_INITIAL = 256| static CONTRol_WINDOW_FirsT = 4| static CONTRol_WINDOW_IS_TEXT_EDITOR = 2| static CONTRol_WINDOW_VIEW_HAS_FOCUS = 1| static DEBUG = false| static disPATCH_HANDLED = 1| static disPATCH_IN_PROGRESS = -1| static disPATCH_NOT_HANDLED = 0| static HIDE_IMPliCIT_ONLY = 1| static HIDE_NOT_ALWAYS = 2| static input_METHOD_NOT_RESPONDING_TIMEOUT = 2500| static MSG_BIND = 2| static MSG_DUMP = 1| static MSG_FLUSH_input_EVENT = 7| static MSG_SEND_input_EVENT = 5| static MSG_SET_ACTIVE = 4| static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9| static MSG_TIMEOUT_input_EVENT = 6| static MSG_UNBIND = 3| static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1| static PENDING_EVENT_COUNTER = java.lang.String [ID=0x6f5bb948]| static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0| static RESulT_HIDDEN = 3| static RESulT_SHOWN = 2| static RESulT_UNCHANGED_HIDDEN = 1| static RESulT_UNCHANGED_SHOWN = 0| static SHOW_FORCED = 2| static SHOW_IMPliCIT = 1| static TAG = java.lang.String [ID=0x6f5a76e0]| static sInstance = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mActive = true| mBindSequence = 1523| mClIEnt = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]| mCompletions = null| mCurChannel = androID.vIEw.inputChannel [ID=0x1304a850]| mCurID = java.lang.String [ID=0x1325dd80]| mCurMethod = com.androID.internal.vIEw.IinputMethodSession$Stub$Proxy [ID=0x1304a840]| mCurRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mCurSender = androID.vIEw.inputmethod.inputMethodManager$ImeinputEventSender [ID=0x12c72850]| mCurrentTextBoxAttribute = androID.vIEw.inputmethod.EditorInfo [ID=0x133036c0]| mCursorAnchorInfo = null| mCursorCandEnd = 0| mCursorCandStart = 0| mCursorRect = androID.graphics.Rect [ID=0x13112d40]| mCursorSelEnd = 0| mCursorSelStart = 0| mDummyinputConnection = androID.vIEw.inputmethod.BaseinputConnection [ID=0x13112dc0]| mFullscreenMode = false| mH = androID.vIEw.inputmethod.inputMethodManager$H [ID=0x13112de0]| mHasBeenInactive = false| mIinputContext = androID.vIEw.inputmethod.inputMethodManager$ControlledinputConnectionWrapper [ID=0x13113310]| mLastSentUserActionNotificationSequenceNumber = -1| mMainLooper = androID.os.Looper [ID=0x12c76be0]| mNextServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mNextUserActionNotificationSequenceNumber = 1| mPendingEventPool = androID.util.Pools$SimplePool [ID=0x13110fe0]| mPendingEvents = androID.util.SparseArray [ID=0x13112d80]| mRequestUpdateCursorAnchorInfoMonitorMode = 0| mServedConnecting = false| mServedinputConnection = null| mServedinputConnectionWrapper = null| mServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mService = com.androID.internal.vIEw.IinputMethodManager$Stub$Proxy [ID=0x13110fc0]| mTmpCursorRect = androID.graphics.Rect [ID=0x13112d20]| mVIEwToScreenMatrix = androID.graphics.Matrix [ID=0x13110fd0]| mVIEwtopleft = int[] [ID=0x13112d60;length=2;size=24]* Instance of com.androID.internal.policy.impl.PhoneWindow$DecorVIEw| mActionMode = null| mActionModePopup = null| mActionModeVIEw = null| mBackgroundFallback = com.androID.internal.Widget.BackgroundFallback [ID=0x12fdd8e0]| mBackgroundpadding = androID.graphics.Rect [ID=0x12ffd9a0]| mbarEnterExitDuration = 250| mChanging = false| mDefaultopacity = -1| mDownY = 0| mDrawingBounds = androID.graphics.Rect [ID=0x12ffd980]| mFeatureID = -1| mFrameOffsets = androID.graphics.Rect [ID=0x12ffd9e0]| mFramepadding = androID.graphics.Rect [ID=0x12ffd9c0]| mHIDeInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffdb00]| mLastBottomInset = 144| mLastHasBottomStableInset = true| mLastHastopStableInset = true| mLastRightInset = 0| mLasttopInset = 75| mLastwindowFlags = -2122252032| mMenuBackground = null| mNavigationcolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c70]| mNavigationGuard = null| mRootScrollY = 0| mShowActionModePopup = null| mShowInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffda60]| mStatuscolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c40]| mStatusGuard = null| mWatchingForMenu = false| this[+++] = com.androID.internal.policy.impl.PhoneWindow [ID=0x12db9e00]| mForeground = null| mForegroundBoundsChanged = true| mForegroundG@R_301_6610@ty = 119| mForegroundInpadding = true| mForegroundpaddingBottom = 0| mForegroundpaddingleft = 0| mForegroundpaddingRight = 0| mForegroundpaddingtop = 0| mForegroundTintList = null| mForegroundTintMode = null| mHasForegroundTint = false| mHasForegroundTintMode = false| mMatchParentChildren = java.util.ArrayList [ID=0x12ffd960]| mMeasureAllChildren = false| mOverlayBounds = androID.graphics.Rect [ID=0x12ffd940]| mSelfBounds = androID.graphics.Rect [ID=0x12ffd920]| mAnimationListener = null| mCachePaint = null| mChildAcceptsDrag = false| mChildCountWithTransIEntState = 0| mChildtransformation = null| mChildren = androID.vIEw.VIEw[] [ID=0x130064c0;length=12]| mChildrenCount = 3| mCurrentDrag = null| mCurrentDragVIEw = null| mdisappearingChildren = null| mDragNotifIEdChildren = null| mFirstHoverTarget = null| mFirsttouchTarget = null| mFocused = androID.Widget.linearLayout [ID=0x12eac800]| mGroupFlags = 2375763| mHoveredSelf = false| mInvalIDateRegion = null| mInvalIDationtransformation = null| mLasttouchDownIndex = 0| mLasttouchDownTime = 137539724| mLasttouchDownX = 605.0| mLasttouchDownY = 1177.0| mLayoutAnimationController = null| mLayoutCalleDWhileSuppressed = false| mLayoutMode = 0| mLayoutTransitionListener = androID.vIEw.VIEwGroup [ID=0x12fdd850]| mLocalPoint = null| mnestedScrollAxes = 0| mOnHIErarchychangelistener = null| mPersistentDrawingCache = 2| mPreSortedChildren = null| mSuppressLayout = false| mTempPoint = float[] [ID=0x12c0a220;length=2;size=24]| mTransition = null| mTransitioningVIEws = null| mVisibilityChangingChildren = null| mAccessibilityCursorposition = -1| mAccessibilityDelegate = null| mAccessibilityTraversalAfterID = -1| mAccessibilityTraversalBeforeID = -1| mAccessibilityVIEwID = -1| mAnimator = null| mAttachInfo = androID.vIEw.VIEw$AttachInfo [ID=0x12c4fcc0]| mAttributes = null| mBackground = androID.graphics.drawable.colorDrawable [ID=0x13014f80]| mBackgroundRenderNode = androID.vIEw.RenderNode [ID=0x12c73740]| mBackgroundResource = 0| mBackgroundSizeChanged = false| mBackgroundTint = null| mBottom = 1920| mCachingFailed = false| mClipBounds = null| mContentDescription = null| mContext = com.couchsurfing.mobile.ui.MainActivity [ID=0x12db9c80]| mCurrentAnimation = null| mDrawableState = null| mDrawingCache = null| mDrawingCacheBackgroundcolor = 0| mfloatingTreeObserver = null| mGhostVIEw = null| mHasPerformedLongPress = false| mID = -1| minputEventConsistencyVerifIEr = null| mKeyedTags = null| mLabelForID = -1| mLastIsOpaque = true| mLayerPaint = null| mLayerType = 0| mLayoutInsets = null| mLayoutParams = androID.vIEw.WindowManager$LayoutParams [ID=0x12f1f7e0]| mleft = 0| mleftpaddingdefined = true| mListenerInfo = androID.vIEw.VIEw$ListenerInfo [ID=0x13109940]| mMatchIDPredicate = null| mMatchLabelForPredicate = null| mMeasureCache = androID.util.LongSparseLongArray [ID=0x13400120]| mMeasuredHeight = 1920| mMeasureDWIDth = 1080| mMinHeight = 0| mMinWIDth = 0| mnestedScrollingParent = null| mNextFocusDownID = -1| mNextFocusForwardID = -1| mNextFocusleftID = -1| mNextFocusRightID = -1| mNextFocusUpID = -1| moldHeightmeasureSpec = 1073743744| molDWIDthMeasureSpec = 1073742904| mOutlineProvIDer = androID.vIEw.VIEwOutlineProvIDer [ID=0x6fcd7240]| mOverScrollMode = 1| mOverlay = null| mpaddingBottom = 0| mpaddingleft = 0| mpaddingRight = 0| mpaddingtop = 0| mParent = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mPendingCheckForLongPress = null| mPendingCheckForTap = null| mPerformClick = null| mPrivateFlags = 25201976| mPrivateFlags2 = 1611867680| mPrivateFlags3 = 4| mRecreatedisplayList = false| mRenderNode = androID.vIEw.RenderNode [ID=0x12ffd880]| mResources = androID.content.res.Resources [ID=0x12c078e0]| mRight = 1080| mRightpaddingdefined = true| mScrollCache = null| mScrollX = 0| mScrollY = 0| mSendVIEwScrolledAccessibilityEvent = null| mSendVIEwStateChangedAccessibilityEvent = null| mSendingHoverAccessibilityEvents = false| mStateListAnimator = null| msystemUIVisibility = 0| mTag = null| mTempnestedScrollConsumed = null| mtop = 0| mtouchDelegate = null| mtouchSlop = 24| mtransformationInfo = androID.vIEw.VIEw$transformationInfo [ID=0x1349e7c0]| mTransIEntStateCount = 0| mTransitionname = null| mUnscaledDrawingCache = null| mUnsetpressedState = null| mUserpaddingBottom = 0| mUserpaddingEnd = -2147483648| mUserpaddingleft = 0| mUserpaddingLeftinitial = 0| mUserpaddingRight = 0| mUserpaddingRightinitial = 0| mUserpaddingStart = -2147483648| mVerticalScrollFactor = 0.0| mVerticalScrollbarposition = 0| mVIEwFlags = 402655360| mWindowAttachCount = 1* Instance of androID.vIEw.VIEw$AttachInfo| mAccessibilityFetchFlags = 0| mAccessibilityFocusDrawable = null| mAccessibilityWindowID = 2147483647| mApplicationScale = 1.0| mCanvas = null| mContentInsets = androID.graphics.Rect [ID=0x13364ee0]| mDeBUGLayout = false| mDisabledsystemUIVisibility = 0| mdisplay = androID.vIEw.display [ID=0x12f75b50]| mdisplayState = 2| mDrawingTime = 137551407| mForceReportNewAttributes = false| mGivenInternalinsets = androID.vIEw.VIEwTreeObserver$InternalinsetsInfo [ID=0x13364f40]| mGlobalsystemUIVisibility = 0| mHandler = androID.vIEw.VIEwRootImpl$VIEwRootHandler [ID=0x13364d00]| mHarDWareAccelerated = true| mHarDWareaccelerationRequested = true| mHarDWareRenderer = androID.vIEw.ThreadedRenderer [ID=0x13323dc0]| mHasNonEmptyGivenInternalinsets = false| mHassystemUIListeners = true| mHasWindowFocus = true| mHighContrastText = false| mIWindowID = null| mIgnoreDirtyState = false| mIntouchMode = true| mInvalIDateChildLocation = int[] [ID=0x13370060;length=2;size=24]| mKeepScreenOn = false| mKeydispatchState = androID.vIEw.KeyEvent$dispatcherState [ID=0x13364fc0]| mOverscanInsets = androID.graphics.Rect [ID=0x13364ec0]| mOverscanRequested = false| mPanelParentwindowToken = null| mPendingAnimatingRenderNodes = null| mPoint = androID.graphics.Point [ID=0x133582f0]| mRecomputeGlobalAttributes = false| mRootCallbacks = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mScalingrequired = false| mScrollContainers = java.util.ArrayList [ID=0x13364fa0]| mSession = androID.vIEw.Iwindowsession$Stub$Proxy [ID=0x13358290]| mSetIgnoreDirtyState = true| mStableInsets = androID.graphics.Rect [ID=0x13364f20]| msystemUIVisibility = 0| mTempArrayList = java.util.ArrayList [ID=0x133701a0]| mTmpInvalRect = androID.graphics.Rect [ID=0x133700c0]| mTmpLocation = int[] [ID=0x13370080;length=2;size=24]| mTmpMatrix = androID.graphics.Matrix [ID=0x133582d0]| mTmpOutline = androID.graphics.Outline [ID=0x13370180]| mTmpRectList = java.util.ArrayList [ID=0x13370120]| mTmptransformLocation = float[] [ID=0x133700a0;length=2;size=24]| mTmptransformRect = androID.graphics.RectF [ID=0x133700e0]| mTmptransformRect1 = androID.graphics.RectF [ID=0x13370100]| mTmptransformation = androID.vIEw.animation.transformation [ID=0x13370140]| mtransparentLocation = int[] [ID=0x13370040;length=2;size=24]| mTreeObserver = androID.vIEw.VIEwTreeObserver [ID=0x133656c0]| mTurnOffWindowResizeAnim = false| mUnbuffereddispatchRequested = false| mUse32BitDrawingCache = true| mVIEwRequestingLayout = null| mVIEwRootImpl = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mVIEwScrollChanged = false| mVIEwVisibilityChanged = false| mVisibleInsets = androID.graphics.Rect [ID=0x13364f00]| mWindow = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowID = null| mWindowleft = 0| mWindowToken = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowtop = 0| mWindowVisibility = 0* Instance of androID.vIEw.VIEwTreeObserver| mAlive = true| mOnComputeInternalinsetsListeners = null| mOnDrawListeners = null| mOnEnteranimationCompleteListeners = null| mOnGlobalFocusListeners = null| mOnGlobalLayoutListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x1315a300]| mOnPreDrawListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x13345760]| mOnScrollChangedListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x12fd3220]| mOntouchModechangelisteners = java.util.concurrent.copyOnWriteArrayList [ID=0x133a1420]| mOnWindowAttachListeners = null| mOnWindowFocusListeners = null| mOnwindowshownListeners = null| mwindowshown = false* Instance of androID.vIEw.VIEwTreeObserver$copyOnWriteArray| mAccess = androID.vIEw.VIEwTreeObserver$copyOnWriteArray$Access [ID=0x12fa1960]| mData = java.util.ArrayList [ID=0x12fd3240]| mDatacopy = null| mStart = false* Instance of java.util.ArrayList| static $staticOverhead = byte[] [ID=0x6fcffb29;length=16;size=32]| static MIN_CAPACITY_INCREMENT = 12| static serialVersionUID = 8683452581122892189| array = java.lang.Object[] [ID=0x13094a40;length=12]| size = 1| modCount = 1* Array of java.lang.Object[]| [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw [ID=0x12fa1950]| [1] = null| [2] = null| [3] = null| [4] = null| [5] = null| [6] = null| [7] = null| [8] = null| [9] = null| [10] = null| [
解决方法 在VIEw实际从窗口中分离之前,尝试更改删除侦听器的代码,如下所示:

[+++]

原因是,在从窗口分离后,getVIEwTreeObserver()返回一个不同的实例(“浮动树观察者”),因此您不会从添加它的同一对象中删除您的侦听器.

UPDATE

由于您正在使用子视图的VIEwTreeObserver,因此行为稍微复杂一点,一种可能的解决方案是将onAttachStatechangelistener添加到scrollVIEw并从那里添加/删除OnScrollChangedListener.

无论如何,有关泄漏的原因:getVIEwTreeObserver()在VIEw从窗口中分离后不会返回相同的实例.调用removeOnScrollChangedListener()可能无效,使原始的OnScrollChangedListener仍然附加到旧的VIEwTreeObserver,从而泄露了Context.

总结

以上是内存溢出为你收集整理的android – 了解ViewTreeObserver泄漏全部内容,希望文章能够帮你解决android – 了解ViewTreeObserver泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用LeakCanary 1.3.1-SNAPSHOT. 我发现有关ViewTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码: private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener; @Override protected void 我正在使用LeakCanary 1.3.1-SNAPSHOT.
我发现有关VIEwTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码:

private VIEwTreeObserver.OnScrollChangedListener scrollVIEwchangelistener;  @OverrIDe protected voID onFinishInflate() {      super.onFinishInflate();      ButterKnife.inject(this);      scrollVIEwchangelistener = new VIEwTreeObserver.OnScrollChangedListener() {      @OverrIDe public voID onScrollChanged() {        EventDetailsVIEw.this.onScrollChanged(scrollVIEw.getScrollY());      }    };      scrollVIEw.getVIEwTreeObserver()        .addOnScrollChangedListener(scrollVIEwchangelistener);  }  @OverrIDe public voID onDetachedFromWindow() {      super.onDetachedFromWindow();      scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);  }

然而,LeakCanary仍然将其报告为泄漏,任何想法为什么?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:* GC ROOT androID.vIEw.inputmethod.inputMethodManager.this
@OverrIDe public voID onDetachedFromWindow() {    scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);    super.onDetachedFromWindow();}
(anonymous class extends com.androID.internal.vIEw.IinputMethodClIEnt$Stub)* references androID.vIEw.inputmethod.inputMethodManager.mCurRootVIEw* references com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.mAttachInfo* references androID.vIEw.VIEw$AttachInfo.mTreeObserver* references androID.vIEw.VIEwTreeObserver.mOnScrollChangedListeners* references androID.vIEw.VIEwTreeObserver$copyOnWriteArray.mData* references java.util.ArrayList.array* references array java.lang.Object[].[0]* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.this (anonymous class implements androID.vIEw.VIEwTreeObserver$OnScrollChangedListener)* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.presenter* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c* Device: LGE Google Nexus 5 hammerhead* AndroID Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT* Durations: watch=5032ms,gc=165ms,heap dump=2932ms,analysis=29907ms* Details:* Instance of androID.vIEw.inputmethod.inputMethodManager| this[+++] = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mDescriptor = java.lang.String [ID=0x6f5e3f38]| mObject = -1601862176| mOwner = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]* Instance of androID.vIEw.inputmethod.inputMethodManager| static $staticOverhead = byte[] [ID=0x6fe25d29;length=240;size=256]| static CONTRol_START_INITIAL = 256| static CONTRol_WINDOW_FirsT = 4| static CONTRol_WINDOW_IS_TEXT_EDITOR = 2| static CONTRol_WINDOW_VIEW_HAS_FOCUS = 1| static DEBUG = false| static disPATCH_HANDLED = 1| static disPATCH_IN_PROGRESS = -1| static disPATCH_NOT_HANDLED = 0| static HIDE_IMPliCIT_ONLY = 1| static HIDE_NOT_ALWAYS = 2| static input_METHOD_NOT_RESPONDING_TIMEOUT = 2500| static MSG_BIND = 2| static MSG_DUMP = 1| static MSG_FLUSH_input_EVENT = 7| static MSG_SEND_input_EVENT = 5| static MSG_SET_ACTIVE = 4| static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9| static MSG_TIMEOUT_input_EVENT = 6| static MSG_UNBIND = 3| static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1| static PENDING_EVENT_COUNTER = java.lang.String [ID=0x6f5bb948]| static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0| static RESulT_HIDDEN = 3| static RESulT_SHOWN = 2| static RESulT_UNCHANGED_HIDDEN = 1| static RESulT_UNCHANGED_SHOWN = 0| static SHOW_FORCED = 2| static SHOW_IMPliCIT = 1| static TAG = java.lang.String [ID=0x6f5a76e0]| static sInstance = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mActive = true| mBindSequence = 1523| mClIEnt = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]| mCompletions = null| mCurChannel = androID.vIEw.inputChannel [ID=0x1304a850]| mCurID = java.lang.String [ID=0x1325dd80]| mCurMethod = com.androID.internal.vIEw.IinputMethodSession$Stub$Proxy [ID=0x1304a840]| mCurRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mCurSender = androID.vIEw.inputmethod.inputMethodManager$ImeinputEventSender [ID=0x12c72850]| mCurrentTextBoxAttribute = androID.vIEw.inputmethod.EditorInfo [ID=0x133036c0]| mCursorAnchorInfo = null| mCursorCandEnd = 0| mCursorCandStart = 0| mCursorRect = androID.graphics.Rect [ID=0x13112d40]| mCursorSelEnd = 0| mCursorSelStart = 0| mDummyinputConnection = androID.vIEw.inputmethod.BaseinputConnection [ID=0x13112dc0]| mFullscreenMode = false| mH = androID.vIEw.inputmethod.inputMethodManager$H [ID=0x13112de0]| mHasBeenInactive = false| mIinputContext = androID.vIEw.inputmethod.inputMethodManager$ControlledinputConnectionWrapper [ID=0x13113310]| mLastSentUserActionNotificationSequenceNumber = -1| mMainLooper = androID.os.Looper [ID=0x12c76be0]| mNextServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mNextUserActionNotificationSequenceNumber = 1| mPendingEventPool = androID.util.Pools$SimplePool [ID=0x13110fe0]| mPendingEvents = androID.util.SparseArray [ID=0x13112d80]| mRequestUpdateCursorAnchorInfoMonitorMode = 0| mServedConnecting = false| mServedinputConnection = null| mServedinputConnectionWrapper = null| mServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mService = com.androID.internal.vIEw.IinputMethodManager$Stub$Proxy [ID=0x13110fc0]| mTmpCursorRect = androID.graphics.Rect [ID=0x13112d20]| mVIEwToScreenMatrix = androID.graphics.Matrix [ID=0x13110fd0]| mVIEwtopleft = int[] [ID=0x13112d60;length=2;size=24]* Instance of com.androID.internal.policy.impl.PhoneWindow$DecorVIEw| mActionMode = null| mActionModePopup = null| mActionModeVIEw = null| mBackgroundFallback = com.androID.internal.Widget.BackgroundFallback [ID=0x12fdd8e0]| mBackgroundpadding = androID.graphics.Rect [ID=0x12ffd9a0]| mbarEnterExitDuration = 250| mChanging = false| mDefaultopacity = -1| mDownY = 0| mDrawingBounds = androID.graphics.Rect [ID=0x12ffd980]| mFeatureID = -1| mFrameOffsets = androID.graphics.Rect [ID=0x12ffd9e0]| mFramepadding = androID.graphics.Rect [ID=0x12ffd9c0]| mHIDeInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffdb00]| mLastBottomInset = 144| mLastHasBottomStableInset = true| mLastHastopStableInset = true| mLastRightInset = 0| mLasttopInset = 75| mLastwindowFlags = -2122252032| mMenuBackground = null| mNavigationcolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c70]| mNavigationGuard = null| mRootScrollY = 0| mShowActionModePopup = null| mShowInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffda60]| mStatuscolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c40]| mStatusGuard = null| mWatchingForMenu = false| this[+++] = com.androID.internal.policy.impl.PhoneWindow [ID=0x12db9e00]| mForeground = null| mForegroundBoundsChanged = true| mForegroundG@R_301_6610@ty = 119| mForegroundInpadding = true| mForegroundpaddingBottom = 0| mForegroundpaddingleft = 0| mForegroundpaddingRight = 0| mForegroundpaddingtop = 0| mForegroundTintList = null| mForegroundTintMode = null| mHasForegroundTint = false| mHasForegroundTintMode = false| mMatchParentChildren = java.util.ArrayList [ID=0x12ffd960]| mMeasureAllChildren = false| mOverlayBounds = androID.graphics.Rect [ID=0x12ffd940]| mSelfBounds = androID.graphics.Rect [ID=0x12ffd920]| mAnimationListener = null| mCachePaint = null| mChildAcceptsDrag = false| mChildCountWithTransIEntState = 0| mChildtransformation = null| mChildren = androID.vIEw.VIEw[] [ID=0x130064c0;length=12]| mChildrenCount = 3| mCurrentDrag = null| mCurrentDragVIEw = null| mdisappearingChildren = null| mDragNotifIEdChildren = null| mFirstHoverTarget = null| mFirsttouchTarget = null| mFocused = androID.Widget.linearLayout [ID=0x12eac800]| mGroupFlags = 2375763| mHoveredSelf = false| mInvalIDateRegion = null| mInvalIDationtransformation = null| mLasttouchDownIndex = 0| mLasttouchDownTime = 137539724| mLasttouchDownX = 605.0| mLasttouchDownY = 1177.0| mLayoutAnimationController = null| mLayoutCalleDWhileSuppressed = false| mLayoutMode = 0| mLayoutTransitionListener = androID.vIEw.VIEwGroup [ID=0x12fdd850]| mLocalPoint = null| mnestedScrollAxes = 0| mOnHIErarchychangelistener = null| mPersistentDrawingCache = 2| mPreSortedChildren = null| mSuppressLayout = false| mTempPoint = float[] [ID=0x12c0a220;length=2;size=24]| mTransition = null| mTransitioningVIEws = null| mVisibilityChangingChildren = null| mAccessibilityCursorposition = -1| mAccessibilityDelegate = null| mAccessibilityTraversalAfterID = -1| mAccessibilityTraversalBeforeID = -1| mAccessibilityVIEwID = -1| mAnimator = null| mAttachInfo = androID.vIEw.VIEw$AttachInfo [ID=0x12c4fcc0]| mAttributes = null| mBackground = androID.graphics.drawable.colorDrawable [ID=0x13014f80]| mBackgroundRenderNode = androID.vIEw.RenderNode [ID=0x12c73740]| mBackgroundResource = 0| mBackgroundSizeChanged = false| mBackgroundTint = null| mBottom = 1920| mCachingFailed = false| mClipBounds = null| mContentDescription = null| mContext = com.couchsurfing.mobile.ui.MainActivity [ID=0x12db9c80]| mCurrentAnimation = null| mDrawableState = null| mDrawingCache = null| mDrawingCacheBackgroundcolor = 0| mfloatingTreeObserver = null| mGhostVIEw = null| mHasPerformedLongPress = false| mID = -1| minputEventConsistencyVerifIEr = null| mKeyedTags = null| mLabelForID = -1| mLastIsOpaque = true| mLayerPaint = null| mLayerType = 0| mLayoutInsets = null| mLayoutParams = androID.vIEw.WindowManager$LayoutParams [ID=0x12f1f7e0]| mleft = 0| mleftpaddingdefined = true| mListenerInfo = androID.vIEw.VIEw$ListenerInfo [ID=0x13109940]| mMatchIDPredicate = null| mMatchLabelForPredicate = null| mMeasureCache = androID.util.LongSparseLongArray [ID=0x13400120]| mMeasuredHeight = 1920| mMeasureDWIDth = 1080| mMinHeight = 0| mMinWIDth = 0| mnestedScrollingParent = null| mNextFocusDownID = -1| mNextFocusForwardID = -1| mNextFocusleftID = -1| mNextFocusRightID = -1| mNextFocusUpID = -1| moldHeightmeasureSpec = 1073743744| molDWIDthMeasureSpec = 1073742904| mOutlineProvIDer = androID.vIEw.VIEwOutlineProvIDer [ID=0x6fcd7240]| mOverScrollMode = 1| mOverlay = null| mpaddingBottom = 0| mpaddingleft = 0| mpaddingRight = 0| mpaddingtop = 0| mParent = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mPendingCheckForLongPress = null| mPendingCheckForTap = null| mPerformClick = null| mPrivateFlags = 25201976| mPrivateFlags2 = 1611867680| mPrivateFlags3 = 4| mRecreatedisplayList = false| mRenderNode = androID.vIEw.RenderNode [ID=0x12ffd880]| mResources = androID.content.res.Resources [ID=0x12c078e0]| mRight = 1080| mRightpaddingdefined = true| mScrollCache = null| mScrollX = 0| mScrollY = 0| mSendVIEwScrolledAccessibilityEvent = null| mSendVIEwStateChangedAccessibilityEvent = null| mSendingHoverAccessibilityEvents = false| mStateListAnimator = null| msystemUIVisibility = 0| mTag = null| mTempnestedScrollConsumed = null| mtop = 0| mtouchDelegate = null| mtouchSlop = 24| mtransformationInfo = androID.vIEw.VIEw$transformationInfo [ID=0x1349e7c0]| mTransIEntStateCount = 0| mTransitionname = null| mUnscaledDrawingCache = null| mUnsetpressedState = null| mUserpaddingBottom = 0| mUserpaddingEnd = -2147483648| mUserpaddingleft = 0| mUserpaddingLeftinitial = 0| mUserpaddingRight = 0| mUserpaddingRightinitial = 0| mUserpaddingStart = -2147483648| mVerticalScrollFactor = 0.0| mVerticalScrollbarposition = 0| mVIEwFlags = 402655360| mWindowAttachCount = 1* Instance of androID.vIEw.VIEw$AttachInfo| mAccessibilityFetchFlags = 0| mAccessibilityFocusDrawable = null| mAccessibilityWindowID = 2147483647| mApplicationScale = 1.0| mCanvas = null| mContentInsets = androID.graphics.Rect [ID=0x13364ee0]| mDeBUGLayout = false| mDisabledsystemUIVisibility = 0| mdisplay = androID.vIEw.display [ID=0x12f75b50]| mdisplayState = 2| mDrawingTime = 137551407| mForceReportNewAttributes = false| mGivenInternalinsets = androID.vIEw.VIEwTreeObserver$InternalinsetsInfo [ID=0x13364f40]| mGlobalsystemUIVisibility = 0| mHandler = androID.vIEw.VIEwRootImpl$VIEwRootHandler [ID=0x13364d00]| mHarDWareAccelerated = true| mHarDWareaccelerationRequested = true| mHarDWareRenderer = androID.vIEw.ThreadedRenderer [ID=0x13323dc0]| mHasNonEmptyGivenInternalinsets = false| mHassystemUIListeners = true| mHasWindowFocus = true| mHighContrastText = false| mIWindowID = null| mIgnoreDirtyState = false| mIntouchMode = true| mInvalIDateChildLocation = int[] [ID=0x13370060;length=2;size=24]| mKeepScreenOn = false| mKeydispatchState = androID.vIEw.KeyEvent$dispatcherState [ID=0x13364fc0]| mOverscanInsets = androID.graphics.Rect [ID=0x13364ec0]| mOverscanRequested = false| mPanelParentwindowToken = null| mPendingAnimatingRenderNodes = null| mPoint = androID.graphics.Point [ID=0x133582f0]| mRecomputeGlobalAttributes = false| mRootCallbacks = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mScalingrequired = false| mScrollContainers = java.util.ArrayList [ID=0x13364fa0]| mSession = androID.vIEw.Iwindowsession$Stub$Proxy [ID=0x13358290]| mSetIgnoreDirtyState = true| mStableInsets = androID.graphics.Rect [ID=0x13364f20]| msystemUIVisibility = 0| mTempArrayList = java.util.ArrayList [ID=0x133701a0]| mTmpInvalRect = androID.graphics.Rect [ID=0x133700c0]| mTmpLocation = int[] [ID=0x13370080;length=2;size=24]| mTmpMatrix = androID.graphics.Matrix [ID=0x133582d0]| mTmpOutline = androID.graphics.Outline [ID=0x13370180]| mTmpRectList = java.util.ArrayList [ID=0x13370120]| mTmptransformLocation = float[] [ID=0x133700a0;length=2;size=24]| mTmptransformRect = androID.graphics.RectF [ID=0x133700e0]| mTmptransformRect1 = androID.graphics.RectF [ID=0x13370100]| mTmptransformation = androID.vIEw.animation.transformation [ID=0x13370140]| mtransparentLocation = int[] [ID=0x13370040;length=2;size=24]| mTreeObserver = androID.vIEw.VIEwTreeObserver [ID=0x133656c0]| mTurnOffWindowResizeAnim = false| mUnbuffereddispatchRequested = false| mUse32BitDrawingCache = true| mVIEwRequestingLayout = null| mVIEwRootImpl = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mVIEwScrollChanged = false| mVIEwVisibilityChanged = false| mVisibleInsets = androID.graphics.Rect [ID=0x13364f00]| mWindow = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowID = null| mWindowleft = 0| mWindowToken = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowtop = 0| mWindowVisibility = 0* Instance of androID.vIEw.VIEwTreeObserver| mAlive = true| mOnComputeInternalinsetsListeners = null| mOnDrawListeners = null| mOnEnteranimationCompleteListeners = null| mOnGlobalFocusListeners = null| mOnGlobalLayoutListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x1315a300]| mOnPreDrawListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x13345760]| mOnScrollChangedListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x12fd3220]| mOntouchModechangelisteners = java.util.concurrent.copyOnWriteArrayList [ID=0x133a1420]| mOnWindowAttachListeners = null| mOnWindowFocusListeners = null| mOnwindowshownListeners = null| mwindowshown = false* Instance of androID.vIEw.VIEwTreeObserver$copyOnWriteArray| mAccess = androID.vIEw.VIEwTreeObserver$copyOnWriteArray$Access [ID=0x12fa1960]| mData = java.util.ArrayList [ID=0x12fd3240]| mDatacopy = null| mStart = false* Instance of java.util.ArrayList| static $staticOverhead = byte[] [ID=0x6fcffb29;length=16;size=32]| static MIN_CAPACITY_INCREMENT = 12| static serialVersionUID = 8683452581122892189| array = java.lang.Object[] [ID=0x13094a40;length=12]| size = 1| modCount = 1* Array of java.lang.Object[]| [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw [ID=0x12fa1950]| [1] = null| [2] = null| [3] = null| [4] = null| [5] = null| [6] = null| [7] = null| [8] = null| [9] = null| [10] = null| [
解决方法 在VIEw实际从窗口中分离之前,尝试更改删除侦听器的代码,如下所示:

[+++]

原因是,在从窗口分离后,getVIEwTreeObserver()返回一个不同的实例(“浮动树观察者”),因此您不会从添加它的同一对象中删除您的侦听器.

UPDATE

由于您正在使用子视图的VIEwTreeObserver,因此行为稍微复杂一点,一种可能的解决方案是将onAttachStatechangelistener添加到scrollVIEw并从那里添加/删除OnScrollChangedListener.

无论如何,有关泄漏的原因:getVIEwTreeObserver()在VIEw从窗口中分离后不会返回相同的实例.调用removeOnScrollChangedListener()可能无效,使原始的OnScrollChangedListener仍然附加到旧的VIEwTreeObserver,从而泄露了Context.

总结

以上是内存溢出为你收集整理的android – 了解ViewTreeObserver泄漏全部内容,希望文章能够帮你解决android – 了解ViewTreeObserver泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用LeakCanary 1.3.1-SNAPSHOT. 我发现有关ViewTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码: private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener; @Override protected void 我正在使用LeakCanary 1.3.1-SNAPSHOT.
我发现有关VIEwTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码:

private VIEwTreeObserver.OnScrollChangedListener scrollVIEwchangelistener;  @OverrIDe protected voID onFinishInflate() {      super.onFinishInflate();      ButterKnife.inject(this);      scrollVIEwchangelistener = new VIEwTreeObserver.OnScrollChangedListener() {      @OverrIDe public voID onScrollChanged() {        EventDetailsVIEw.this.onScrollChanged(scrollVIEw.getScrollY());      }    };      scrollVIEw.getVIEwTreeObserver()        .addOnScrollChangedListener(scrollVIEwchangelistener);  }  @OverrIDe public voID onDetachedFromWindow() {      super.onDetachedFromWindow();      scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);  }

然而,LeakCanary仍然将其报告为泄漏,任何想法为什么?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:* GC ROOT androID.vIEw.inputmethod.inputMethodManager.this
@OverrIDe public voID onDetachedFromWindow() {    scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);    super.onDetachedFromWindow();}
(anonymous class extends com.androID.internal.vIEw.IinputMethodClIEnt$Stub)* references androID.vIEw.inputmethod.inputMethodManager.mCurRootVIEw* references com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.mAttachInfo* references androID.vIEw.VIEw$AttachInfo.mTreeObserver* references androID.vIEw.VIEwTreeObserver.mOnScrollChangedListeners* references androID.vIEw.VIEwTreeObserver$copyOnWriteArray.mData* references java.util.ArrayList.array* references array java.lang.Object[].[0]* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.this (anonymous class implements androID.vIEw.VIEwTreeObserver$OnScrollChangedListener)* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.presenter* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c* Device: LGE Google Nexus 5 hammerhead* AndroID Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT* Durations: watch=5032ms,gc=165ms,heap dump=2932ms,analysis=29907ms* Details:* Instance of androID.vIEw.inputmethod.inputMethodManager| this = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mDescriptor = java.lang.String [ID=0x6f5e3f38]| mObject = -1601862176| mOwner = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]* Instance of androID.vIEw.inputmethod.inputMethodManager| static $staticOverhead = byte[] [ID=0x6fe25d29;length=240;size=256]| static CONTRol_START_INITIAL = 256| static CONTRol_WINDOW_FirsT = 4| static CONTRol_WINDOW_IS_TEXT_EDITOR = 2| static CONTRol_WINDOW_VIEW_HAS_FOCUS = 1| static DEBUG = false| static disPATCH_HANDLED = 1| static disPATCH_IN_PROGRESS = -1| static disPATCH_NOT_HANDLED = 0| static HIDE_IMPliCIT_ONLY = 1| static HIDE_NOT_ALWAYS = 2| static input_METHOD_NOT_RESPONDING_TIMEOUT = 2500| static MSG_BIND = 2| static MSG_DUMP = 1| static MSG_FLUSH_input_EVENT = 7| static MSG_SEND_input_EVENT = 5| static MSG_SET_ACTIVE = 4| static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9| static MSG_TIMEOUT_input_EVENT = 6| static MSG_UNBIND = 3| static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1| static PENDING_EVENT_COUNTER = java.lang.String [ID=0x6f5bb948]| static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0| static RESulT_HIDDEN = 3| static RESulT_SHOWN = 2| static RESulT_UNCHANGED_HIDDEN = 1| static RESulT_UNCHANGED_SHOWN = 0| static SHOW_FORCED = 2| static SHOW_IMPliCIT = 1| static TAG = java.lang.String [ID=0x6f5a76e0]| static sInstance = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mActive = true| mBindSequence = 1523| mClIEnt = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]| mCompletions = null| mCurChannel = androID.vIEw.inputChannel [ID=0x1304a850]| mCurID = java.lang.String [ID=0x1325dd80]| mCurMethod = com.androID.internal.vIEw.IinputMethodSession$Stub$Proxy [ID=0x1304a840]| mCurRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mCurSender = androID.vIEw.inputmethod.inputMethodManager$ImeinputEventSender [ID=0x12c72850]| mCurrentTextBoxAttribute = androID.vIEw.inputmethod.EditorInfo [ID=0x133036c0]| mCursorAnchorInfo = null| mCursorCandEnd = 0| mCursorCandStart = 0| mCursorRect = androID.graphics.Rect [ID=0x13112d40]| mCursorSelEnd = 0| mCursorSelStart = 0| mDummyinputConnection = androID.vIEw.inputmethod.BaseinputConnection [ID=0x13112dc0]| mFullscreenMode = false| mH = androID.vIEw.inputmethod.inputMethodManager$H [ID=0x13112de0]| mHasBeenInactive = false| mIinputContext = androID.vIEw.inputmethod.inputMethodManager$ControlledinputConnectionWrapper [ID=0x13113310]| mLastSentUserActionNotificationSequenceNumber = -1| mMainLooper = androID.os.Looper [ID=0x12c76be0]| mNextServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mNextUserActionNotificationSequenceNumber = 1| mPendingEventPool = androID.util.Pools$SimplePool [ID=0x13110fe0]| mPendingEvents = androID.util.SparseArray [ID=0x13112d80]| mRequestUpdateCursorAnchorInfoMonitorMode = 0| mServedConnecting = false| mServedinputConnection = null| mServedinputConnectionWrapper = null| mServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mService = com.androID.internal.vIEw.IinputMethodManager$Stub$Proxy [ID=0x13110fc0]| mTmpCursorRect = androID.graphics.Rect [ID=0x13112d20]| mVIEwToScreenMatrix = androID.graphics.Matrix [ID=0x13110fd0]| mVIEwtopleft = int[] [ID=0x13112d60;length=2;size=24]* Instance of com.androID.internal.policy.impl.PhoneWindow$DecorVIEw| mActionMode = null| mActionModePopup = null| mActionModeVIEw = null| mBackgroundFallback = com.androID.internal.Widget.BackgroundFallback [ID=0x12fdd8e0]| mBackgroundpadding = androID.graphics.Rect [ID=0x12ffd9a0]| mbarEnterExitDuration = 250| mChanging = false| mDefaultopacity = -1| mDownY = 0| mDrawingBounds = androID.graphics.Rect [ID=0x12ffd980]| mFeatureID = -1| mFrameOffsets = androID.graphics.Rect [ID=0x12ffd9e0]| mFramepadding = androID.graphics.Rect [ID=0x12ffd9c0]| mHIDeInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffdb00]| mLastBottomInset = 144| mLastHasBottomStableInset = true| mLastHastopStableInset = true| mLastRightInset = 0| mLasttopInset = 75| mLastwindowFlags = -2122252032| mMenuBackground = null| mNavigationcolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c70]| mNavigationGuard = null| mRootScrollY = 0| mShowActionModePopup = null| mShowInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffda60]| mStatuscolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c40]| mStatusGuard = null| mWatchingForMenu = false| this[+++] = com.androID.internal.policy.impl.PhoneWindow [ID=0x12db9e00]| mForeground = null| mForegroundBoundsChanged = true| mForegroundG@R_301_6610@ty = 119| mForegroundInpadding = true| mForegroundpaddingBottom = 0| mForegroundpaddingleft = 0| mForegroundpaddingRight = 0| mForegroundpaddingtop = 0| mForegroundTintList = null| mForegroundTintMode = null| mHasForegroundTint = false| mHasForegroundTintMode = false| mMatchParentChildren = java.util.ArrayList [ID=0x12ffd960]| mMeasureAllChildren = false| mOverlayBounds = androID.graphics.Rect [ID=0x12ffd940]| mSelfBounds = androID.graphics.Rect [ID=0x12ffd920]| mAnimationListener = null| mCachePaint = null| mChildAcceptsDrag = false| mChildCountWithTransIEntState = 0| mChildtransformation = null| mChildren = androID.vIEw.VIEw[] [ID=0x130064c0;length=12]| mChildrenCount = 3| mCurrentDrag = null| mCurrentDragVIEw = null| mdisappearingChildren = null| mDragNotifIEdChildren = null| mFirstHoverTarget = null| mFirsttouchTarget = null| mFocused = androID.Widget.linearLayout [ID=0x12eac800]| mGroupFlags = 2375763| mHoveredSelf = false| mInvalIDateRegion = null| mInvalIDationtransformation = null| mLasttouchDownIndex = 0| mLasttouchDownTime = 137539724| mLasttouchDownX = 605.0| mLasttouchDownY = 1177.0| mLayoutAnimationController = null| mLayoutCalleDWhileSuppressed = false| mLayoutMode = 0| mLayoutTransitionListener = androID.vIEw.VIEwGroup [ID=0x12fdd850]| mLocalPoint = null| mnestedScrollAxes = 0| mOnHIErarchychangelistener = null| mPersistentDrawingCache = 2| mPreSortedChildren = null| mSuppressLayout = false| mTempPoint = float[] [ID=0x12c0a220;length=2;size=24]| mTransition = null| mTransitioningVIEws = null| mVisibilityChangingChildren = null| mAccessibilityCursorposition = -1| mAccessibilityDelegate = null| mAccessibilityTraversalAfterID = -1| mAccessibilityTraversalBeforeID = -1| mAccessibilityVIEwID = -1| mAnimator = null| mAttachInfo = androID.vIEw.VIEw$AttachInfo [ID=0x12c4fcc0]| mAttributes = null| mBackground = androID.graphics.drawable.colorDrawable [ID=0x13014f80]| mBackgroundRenderNode = androID.vIEw.RenderNode [ID=0x12c73740]| mBackgroundResource = 0| mBackgroundSizeChanged = false| mBackgroundTint = null| mBottom = 1920| mCachingFailed = false| mClipBounds = null| mContentDescription = null| mContext = com.couchsurfing.mobile.ui.MainActivity [ID=0x12db9c80]| mCurrentAnimation = null| mDrawableState = null| mDrawingCache = null| mDrawingCacheBackgroundcolor = 0| mfloatingTreeObserver = null| mGhostVIEw = null| mHasPerformedLongPress = false| mID = -1| minputEventConsistencyVerifIEr = null| mKeyedTags = null| mLabelForID = -1| mLastIsOpaque = true| mLayerPaint = null| mLayerType = 0| mLayoutInsets = null| mLayoutParams = androID.vIEw.WindowManager$LayoutParams [ID=0x12f1f7e0]| mleft = 0| mleftpaddingdefined = true| mListenerInfo = androID.vIEw.VIEw$ListenerInfo [ID=0x13109940]| mMatchIDPredicate = null| mMatchLabelForPredicate = null| mMeasureCache = androID.util.LongSparseLongArray [ID=0x13400120]| mMeasuredHeight = 1920| mMeasureDWIDth = 1080| mMinHeight = 0| mMinWIDth = 0| mnestedScrollingParent = null| mNextFocusDownID = -1| mNextFocusForwardID = -1| mNextFocusleftID = -1| mNextFocusRightID = -1| mNextFocusUpID = -1| moldHeightmeasureSpec = 1073743744| molDWIDthMeasureSpec = 1073742904| mOutlineProvIDer = androID.vIEw.VIEwOutlineProvIDer [ID=0x6fcd7240]| mOverScrollMode = 1| mOverlay = null| mpaddingBottom = 0| mpaddingleft = 0| mpaddingRight = 0| mpaddingtop = 0| mParent = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mPendingCheckForLongPress = null| mPendingCheckForTap = null| mPerformClick = null| mPrivateFlags = 25201976| mPrivateFlags2 = 1611867680| mPrivateFlags3 = 4| mRecreatedisplayList = false| mRenderNode = androID.vIEw.RenderNode [ID=0x12ffd880]| mResources = androID.content.res.Resources [ID=0x12c078e0]| mRight = 1080| mRightpaddingdefined = true| mScrollCache = null| mScrollX = 0| mScrollY = 0| mSendVIEwScrolledAccessibilityEvent = null| mSendVIEwStateChangedAccessibilityEvent = null| mSendingHoverAccessibilityEvents = false| mStateListAnimator = null| msystemUIVisibility = 0| mTag = null| mTempnestedScrollConsumed = null| mtop = 0| mtouchDelegate = null| mtouchSlop = 24| mtransformationInfo = androID.vIEw.VIEw$transformationInfo [ID=0x1349e7c0]| mTransIEntStateCount = 0| mTransitionname = null| mUnscaledDrawingCache = null| mUnsetpressedState = null| mUserpaddingBottom = 0| mUserpaddingEnd = -2147483648| mUserpaddingleft = 0| mUserpaddingLeftinitial = 0| mUserpaddingRight = 0| mUserpaddingRightinitial = 0| mUserpaddingStart = -2147483648| mVerticalScrollFactor = 0.0| mVerticalScrollbarposition = 0| mVIEwFlags = 402655360| mWindowAttachCount = 1* Instance of androID.vIEw.VIEw$AttachInfo| mAccessibilityFetchFlags = 0| mAccessibilityFocusDrawable = null| mAccessibilityWindowID = 2147483647| mApplicationScale = 1.0| mCanvas = null| mContentInsets = androID.graphics.Rect [ID=0x13364ee0]| mDeBUGLayout = false| mDisabledsystemUIVisibility = 0| mdisplay = androID.vIEw.display [ID=0x12f75b50]| mdisplayState = 2| mDrawingTime = 137551407| mForceReportNewAttributes = false| mGivenInternalinsets = androID.vIEw.VIEwTreeObserver$InternalinsetsInfo [ID=0x13364f40]| mGlobalsystemUIVisibility = 0| mHandler = androID.vIEw.VIEwRootImpl$VIEwRootHandler [ID=0x13364d00]| mHarDWareAccelerated = true| mHarDWareaccelerationRequested = true| mHarDWareRenderer = androID.vIEw.ThreadedRenderer [ID=0x13323dc0]| mHasNonEmptyGivenInternalinsets = false| mHassystemUIListeners = true| mHasWindowFocus = true| mHighContrastText = false| mIWindowID = null| mIgnoreDirtyState = false| mIntouchMode = true| mInvalIDateChildLocation = int[] [ID=0x13370060;length=2;size=24]| mKeepScreenOn = false| mKeydispatchState = androID.vIEw.KeyEvent$dispatcherState [ID=0x13364fc0]| mOverscanInsets = androID.graphics.Rect [ID=0x13364ec0]| mOverscanRequested = false| mPanelParentwindowToken = null| mPendingAnimatingRenderNodes = null| mPoint = androID.graphics.Point [ID=0x133582f0]| mRecomputeGlobalAttributes = false| mRootCallbacks = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mScalingrequired = false| mScrollContainers = java.util.ArrayList [ID=0x13364fa0]| mSession = androID.vIEw.Iwindowsession$Stub$Proxy [ID=0x13358290]| mSetIgnoreDirtyState = true| mStableInsets = androID.graphics.Rect [ID=0x13364f20]| msystemUIVisibility = 0| mTempArrayList = java.util.ArrayList [ID=0x133701a0]| mTmpInvalRect = androID.graphics.Rect [ID=0x133700c0]| mTmpLocation = int[] [ID=0x13370080;length=2;size=24]| mTmpMatrix = androID.graphics.Matrix [ID=0x133582d0]| mTmpOutline = androID.graphics.Outline [ID=0x13370180]| mTmpRectList = java.util.ArrayList [ID=0x13370120]| mTmptransformLocation = float[] [ID=0x133700a0;length=2;size=24]| mTmptransformRect = androID.graphics.RectF [ID=0x133700e0]| mTmptransformRect1 = androID.graphics.RectF [ID=0x13370100]| mTmptransformation = androID.vIEw.animation.transformation [ID=0x13370140]| mtransparentLocation = int[] [ID=0x13370040;length=2;size=24]| mTreeObserver = androID.vIEw.VIEwTreeObserver [ID=0x133656c0]| mTurnOffWindowResizeAnim = false| mUnbuffereddispatchRequested = false| mUse32BitDrawingCache = true| mVIEwRequestingLayout = null| mVIEwRootImpl = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mVIEwScrollChanged = false| mVIEwVisibilityChanged = false| mVisibleInsets = androID.graphics.Rect [ID=0x13364f00]| mWindow = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowID = null| mWindowleft = 0| mWindowToken = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowtop = 0| mWindowVisibility = 0* Instance of androID.vIEw.VIEwTreeObserver| mAlive = true| mOnComputeInternalinsetsListeners = null| mOnDrawListeners = null| mOnEnteranimationCompleteListeners = null| mOnGlobalFocusListeners = null| mOnGlobalLayoutListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x1315a300]| mOnPreDrawListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x13345760]| mOnScrollChangedListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x12fd3220]| mOntouchModechangelisteners = java.util.concurrent.copyOnWriteArrayList [ID=0x133a1420]| mOnWindowAttachListeners = null| mOnWindowFocusListeners = null| mOnwindowshownListeners = null| mwindowshown = false* Instance of androID.vIEw.VIEwTreeObserver$copyOnWriteArray| mAccess = androID.vIEw.VIEwTreeObserver$copyOnWriteArray$Access [ID=0x12fa1960]| mData = java.util.ArrayList [ID=0x12fd3240]| mDatacopy = null| mStart = false* Instance of java.util.ArrayList| static $staticOverhead = byte[] [ID=0x6fcffb29;length=16;size=32]| static MIN_CAPACITY_INCREMENT = 12| static serialVersionUID = 8683452581122892189| array = java.lang.Object[] [ID=0x13094a40;length=12]| size = 1| modCount = 1* Array of java.lang.Object[]| [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw [ID=0x12fa1950]| [1] = null| [2] = null| [3] = null| [4] = null| [5] = null| [6] = null| [7] = null| [8] = null| [9] = null| [10] = null| [
解决方法 在VIEw实际从窗口中分离之前,尝试更改删除侦听器的代码,如下所示:

[+++]

原因是,在从窗口分离后,getVIEwTreeObserver()返回一个不同的实例(“浮动树观察者”),因此您不会从添加它的同一对象中删除您的侦听器.

UPDATE

由于您正在使用子视图的VIEwTreeObserver,因此行为稍微复杂一点,一种可能的解决方案是将onAttachStatechangelistener添加到scrollVIEw并从那里添加/删除OnScrollChangedListener.

无论如何,有关泄漏的原因:getVIEwTreeObserver()在VIEw从窗口中分离后不会返回相同的实例.调用removeOnScrollChangedListener()可能无效,使原始的OnScrollChangedListener仍然附加到旧的VIEwTreeObserver,从而泄露了Context.

总结

以上是内存溢出为你收集整理的android – 了解ViewTreeObserver泄漏全部内容,希望文章能够帮你解决android – 了解ViewTreeObserver泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用LeakCanary 1.3.1-SNAPSHOT. 我发现有关ViewTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码: private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener; @Override protected void 我正在使用LeakCanary 1.3.1-SNAPSHOT.
我发现有关VIEwTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码:

private VIEwTreeObserver.OnScrollChangedListener scrollVIEwchangelistener;  @OverrIDe protected voID onFinishInflate() {      super.onFinishInflate();      ButterKnife.inject(this);      scrollVIEwchangelistener = new VIEwTreeObserver.OnScrollChangedListener() {      @OverrIDe public voID onScrollChanged() {        EventDetailsVIEw.this.onScrollChanged(scrollVIEw.getScrollY());      }    };      scrollVIEw.getVIEwTreeObserver()        .addOnScrollChangedListener(scrollVIEwchangelistener);  }  @OverrIDe public voID onDetachedFromWindow() {      super.onDetachedFromWindow();      scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);  }

然而,LeakCanary仍然将其报告为泄漏,任何想法为什么?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:* GC ROOT androID.vIEw.inputmethod.inputMethodManager.this
@OverrIDe public voID onDetachedFromWindow() {    scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);    super.onDetachedFromWindow();}
(anonymous class extends com.androID.internal.vIEw.IinputMethodClIEnt$Stub)* references androID.vIEw.inputmethod.inputMethodManager.mCurRootVIEw* references com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.mAttachInfo* references androID.vIEw.VIEw$AttachInfo.mTreeObserver* references androID.vIEw.VIEwTreeObserver.mOnScrollChangedListeners* references androID.vIEw.VIEwTreeObserver$copyOnWriteArray.mData* references java.util.ArrayList.array* references array java.lang.Object[].[0]* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.this (anonymous class implements androID.vIEw.VIEwTreeObserver$OnScrollChangedListener)* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.presenter* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c* Device: LGE Google Nexus 5 hammerhead* AndroID Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT* Durations: watch=5032ms,gc=165ms,heap dump=2932ms,analysis=29907ms* Details:* Instance of androID.vIEw.inputmethod.inputMethodManager| this = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mDescriptor = java.lang.String [ID=0x6f5e3f38]| mObject = -1601862176| mOwner = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]* Instance of androID.vIEw.inputmethod.inputMethodManager| static $staticOverhead = byte[] [ID=0x6fe25d29;length=240;size=256]| static CONTRol_START_INITIAL = 256| static CONTRol_WINDOW_FirsT = 4| static CONTRol_WINDOW_IS_TEXT_EDITOR = 2| static CONTRol_WINDOW_VIEW_HAS_FOCUS = 1| static DEBUG = false| static disPATCH_HANDLED = 1| static disPATCH_IN_PROGRESS = -1| static disPATCH_NOT_HANDLED = 0| static HIDE_IMPliCIT_ONLY = 1| static HIDE_NOT_ALWAYS = 2| static input_METHOD_NOT_RESPONDING_TIMEOUT = 2500| static MSG_BIND = 2| static MSG_DUMP = 1| static MSG_FLUSH_input_EVENT = 7| static MSG_SEND_input_EVENT = 5| static MSG_SET_ACTIVE = 4| static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9| static MSG_TIMEOUT_input_EVENT = 6| static MSG_UNBIND = 3| static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1| static PENDING_EVENT_COUNTER = java.lang.String [ID=0x6f5bb948]| static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0| static RESulT_HIDDEN = 3| static RESulT_SHOWN = 2| static RESulT_UNCHANGED_HIDDEN = 1| static RESulT_UNCHANGED_SHOWN = 0| static SHOW_FORCED = 2| static SHOW_IMPliCIT = 1| static TAG = java.lang.String [ID=0x6f5a76e0]| static sInstance = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mActive = true| mBindSequence = 1523| mClIEnt = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]| mCompletions = null| mCurChannel = androID.vIEw.inputChannel [ID=0x1304a850]| mCurID = java.lang.String [ID=0x1325dd80]| mCurMethod = com.androID.internal.vIEw.IinputMethodSession$Stub$Proxy [ID=0x1304a840]| mCurRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mCurSender = androID.vIEw.inputmethod.inputMethodManager$ImeinputEventSender [ID=0x12c72850]| mCurrentTextBoxAttribute = androID.vIEw.inputmethod.EditorInfo [ID=0x133036c0]| mCursorAnchorInfo = null| mCursorCandEnd = 0| mCursorCandStart = 0| mCursorRect = androID.graphics.Rect [ID=0x13112d40]| mCursorSelEnd = 0| mCursorSelStart = 0| mDummyinputConnection = androID.vIEw.inputmethod.BaseinputConnection [ID=0x13112dc0]| mFullscreenMode = false| mH = androID.vIEw.inputmethod.inputMethodManager$H [ID=0x13112de0]| mHasBeenInactive = false| mIinputContext = androID.vIEw.inputmethod.inputMethodManager$ControlledinputConnectionWrapper [ID=0x13113310]| mLastSentUserActionNotificationSequenceNumber = -1| mMainLooper = androID.os.Looper [ID=0x12c76be0]| mNextServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mNextUserActionNotificationSequenceNumber = 1| mPendingEventPool = androID.util.Pools$SimplePool [ID=0x13110fe0]| mPendingEvents = androID.util.SparseArray [ID=0x13112d80]| mRequestUpdateCursorAnchorInfoMonitorMode = 0| mServedConnecting = false| mServedinputConnection = null| mServedinputConnectionWrapper = null| mServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mService = com.androID.internal.vIEw.IinputMethodManager$Stub$Proxy [ID=0x13110fc0]| mTmpCursorRect = androID.graphics.Rect [ID=0x13112d20]| mVIEwToScreenMatrix = androID.graphics.Matrix [ID=0x13110fd0]| mVIEwtopleft = int[] [ID=0x13112d60;length=2;size=24]* Instance of com.androID.internal.policy.impl.PhoneWindow$DecorVIEw| mActionMode = null| mActionModePopup = null| mActionModeVIEw = null| mBackgroundFallback = com.androID.internal.Widget.BackgroundFallback [ID=0x12fdd8e0]| mBackgroundpadding = androID.graphics.Rect [ID=0x12ffd9a0]| mbarEnterExitDuration = 250| mChanging = false| mDefaultopacity = -1| mDownY = 0| mDrawingBounds = androID.graphics.Rect [ID=0x12ffd980]| mFeatureID = -1| mFrameOffsets = androID.graphics.Rect [ID=0x12ffd9e0]| mFramepadding = androID.graphics.Rect [ID=0x12ffd9c0]| mHIDeInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffdb00]| mLastBottomInset = 144| mLastHasBottomStableInset = true| mLastHastopStableInset = true| mLastRightInset = 0| mLasttopInset = 75| mLastwindowFlags = -2122252032| mMenuBackground = null| mNavigationcolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c70]| mNavigationGuard = null| mRootScrollY = 0| mShowActionModePopup = null| mShowInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffda60]| mStatuscolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c40]| mStatusGuard = null| mWatchingForMenu = false| this = com.androID.internal.policy.impl.PhoneWindow [ID=0x12db9e00]| mForeground = null| mForegroundBoundsChanged = true| mForegroundG@R_301_6610@ty = 119| mForegroundInpadding = true| mForegroundpaddingBottom = 0| mForegroundpaddingleft = 0| mForegroundpaddingRight = 0| mForegroundpaddingtop = 0| mForegroundTintList = null| mForegroundTintMode = null| mHasForegroundTint = false| mHasForegroundTintMode = false| mMatchParentChildren = java.util.ArrayList [ID=0x12ffd960]| mMeasureAllChildren = false| mOverlayBounds = androID.graphics.Rect [ID=0x12ffd940]| mSelfBounds = androID.graphics.Rect [ID=0x12ffd920]| mAnimationListener = null| mCachePaint = null| mChildAcceptsDrag = false| mChildCountWithTransIEntState = 0| mChildtransformation = null| mChildren = androID.vIEw.VIEw[] [ID=0x130064c0;length=12]| mChildrenCount = 3| mCurrentDrag = null| mCurrentDragVIEw = null| mdisappearingChildren = null| mDragNotifIEdChildren = null| mFirstHoverTarget = null| mFirsttouchTarget = null| mFocused = androID.Widget.linearLayout [ID=0x12eac800]| mGroupFlags = 2375763| mHoveredSelf = false| mInvalIDateRegion = null| mInvalIDationtransformation = null| mLasttouchDownIndex = 0| mLasttouchDownTime = 137539724| mLasttouchDownX = 605.0| mLasttouchDownY = 1177.0| mLayoutAnimationController = null| mLayoutCalleDWhileSuppressed = false| mLayoutMode = 0| mLayoutTransitionListener = androID.vIEw.VIEwGroup [ID=0x12fdd850]| mLocalPoint = null| mnestedScrollAxes = 0| mOnHIErarchychangelistener = null| mPersistentDrawingCache = 2| mPreSortedChildren = null| mSuppressLayout = false| mTempPoint = float[] [ID=0x12c0a220;length=2;size=24]| mTransition = null| mTransitioningVIEws = null| mVisibilityChangingChildren = null| mAccessibilityCursorposition = -1| mAccessibilityDelegate = null| mAccessibilityTraversalAfterID = -1| mAccessibilityTraversalBeforeID = -1| mAccessibilityVIEwID = -1| mAnimator = null| mAttachInfo = androID.vIEw.VIEw$AttachInfo [ID=0x12c4fcc0]| mAttributes = null| mBackground = androID.graphics.drawable.colorDrawable [ID=0x13014f80]| mBackgroundRenderNode = androID.vIEw.RenderNode [ID=0x12c73740]| mBackgroundResource = 0| mBackgroundSizeChanged = false| mBackgroundTint = null| mBottom = 1920| mCachingFailed = false| mClipBounds = null| mContentDescription = null| mContext = com.couchsurfing.mobile.ui.MainActivity [ID=0x12db9c80]| mCurrentAnimation = null| mDrawableState = null| mDrawingCache = null| mDrawingCacheBackgroundcolor = 0| mfloatingTreeObserver = null| mGhostVIEw = null| mHasPerformedLongPress = false| mID = -1| minputEventConsistencyVerifIEr = null| mKeyedTags = null| mLabelForID = -1| mLastIsOpaque = true| mLayerPaint = null| mLayerType = 0| mLayoutInsets = null| mLayoutParams = androID.vIEw.WindowManager$LayoutParams [ID=0x12f1f7e0]| mleft = 0| mleftpaddingdefined = true| mListenerInfo = androID.vIEw.VIEw$ListenerInfo [ID=0x13109940]| mMatchIDPredicate = null| mMatchLabelForPredicate = null| mMeasureCache = androID.util.LongSparseLongArray [ID=0x13400120]| mMeasuredHeight = 1920| mMeasureDWIDth = 1080| mMinHeight = 0| mMinWIDth = 0| mnestedScrollingParent = null| mNextFocusDownID = -1| mNextFocusForwardID = -1| mNextFocusleftID = -1| mNextFocusRightID = -1| mNextFocusUpID = -1| moldHeightmeasureSpec = 1073743744| molDWIDthMeasureSpec = 1073742904| mOutlineProvIDer = androID.vIEw.VIEwOutlineProvIDer [ID=0x6fcd7240]| mOverScrollMode = 1| mOverlay = null| mpaddingBottom = 0| mpaddingleft = 0| mpaddingRight = 0| mpaddingtop = 0| mParent = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mPendingCheckForLongPress = null| mPendingCheckForTap = null| mPerformClick = null| mPrivateFlags = 25201976| mPrivateFlags2 = 1611867680| mPrivateFlags3 = 4| mRecreatedisplayList = false| mRenderNode = androID.vIEw.RenderNode [ID=0x12ffd880]| mResources = androID.content.res.Resources [ID=0x12c078e0]| mRight = 1080| mRightpaddingdefined = true| mScrollCache = null| mScrollX = 0| mScrollY = 0| mSendVIEwScrolledAccessibilityEvent = null| mSendVIEwStateChangedAccessibilityEvent = null| mSendingHoverAccessibilityEvents = false| mStateListAnimator = null| msystemUIVisibility = 0| mTag = null| mTempnestedScrollConsumed = null| mtop = 0| mtouchDelegate = null| mtouchSlop = 24| mtransformationInfo = androID.vIEw.VIEw$transformationInfo [ID=0x1349e7c0]| mTransIEntStateCount = 0| mTransitionname = null| mUnscaledDrawingCache = null| mUnsetpressedState = null| mUserpaddingBottom = 0| mUserpaddingEnd = -2147483648| mUserpaddingleft = 0| mUserpaddingLeftinitial = 0| mUserpaddingRight = 0| mUserpaddingRightinitial = 0| mUserpaddingStart = -2147483648| mVerticalScrollFactor = 0.0| mVerticalScrollbarposition = 0| mVIEwFlags = 402655360| mWindowAttachCount = 1* Instance of androID.vIEw.VIEw$AttachInfo| mAccessibilityFetchFlags = 0| mAccessibilityFocusDrawable = null| mAccessibilityWindowID = 2147483647| mApplicationScale = 1.0| mCanvas = null| mContentInsets = androID.graphics.Rect [ID=0x13364ee0]| mDeBUGLayout = false| mDisabledsystemUIVisibility = 0| mdisplay = androID.vIEw.display [ID=0x12f75b50]| mdisplayState = 2| mDrawingTime = 137551407| mForceReportNewAttributes = false| mGivenInternalinsets = androID.vIEw.VIEwTreeObserver$InternalinsetsInfo [ID=0x13364f40]| mGlobalsystemUIVisibility = 0| mHandler = androID.vIEw.VIEwRootImpl$VIEwRootHandler [ID=0x13364d00]| mHarDWareAccelerated = true| mHarDWareaccelerationRequested = true| mHarDWareRenderer = androID.vIEw.ThreadedRenderer [ID=0x13323dc0]| mHasNonEmptyGivenInternalinsets = false| mHassystemUIListeners = true| mHasWindowFocus = true| mHighContrastText = false| mIWindowID = null| mIgnoreDirtyState = false| mIntouchMode = true| mInvalIDateChildLocation = int[] [ID=0x13370060;length=2;size=24]| mKeepScreenOn = false| mKeydispatchState = androID.vIEw.KeyEvent$dispatcherState [ID=0x13364fc0]| mOverscanInsets = androID.graphics.Rect [ID=0x13364ec0]| mOverscanRequested = false| mPanelParentwindowToken = null| mPendingAnimatingRenderNodes = null| mPoint = androID.graphics.Point [ID=0x133582f0]| mRecomputeGlobalAttributes = false| mRootCallbacks = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mScalingrequired = false| mScrollContainers = java.util.ArrayList [ID=0x13364fa0]| mSession = androID.vIEw.Iwindowsession$Stub$Proxy [ID=0x13358290]| mSetIgnoreDirtyState = true| mStableInsets = androID.graphics.Rect [ID=0x13364f20]| msystemUIVisibility = 0| mTempArrayList = java.util.ArrayList [ID=0x133701a0]| mTmpInvalRect = androID.graphics.Rect [ID=0x133700c0]| mTmpLocation = int[] [ID=0x13370080;length=2;size=24]| mTmpMatrix = androID.graphics.Matrix [ID=0x133582d0]| mTmpOutline = androID.graphics.Outline [ID=0x13370180]| mTmpRectList = java.util.ArrayList [ID=0x13370120]| mTmptransformLocation = float[] [ID=0x133700a0;length=2;size=24]| mTmptransformRect = androID.graphics.RectF [ID=0x133700e0]| mTmptransformRect1 = androID.graphics.RectF [ID=0x13370100]| mTmptransformation = androID.vIEw.animation.transformation [ID=0x13370140]| mtransparentLocation = int[] [ID=0x13370040;length=2;size=24]| mTreeObserver = androID.vIEw.VIEwTreeObserver [ID=0x133656c0]| mTurnOffWindowResizeAnim = false| mUnbuffereddispatchRequested = false| mUse32BitDrawingCache = true| mVIEwRequestingLayout = null| mVIEwRootImpl = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mVIEwScrollChanged = false| mVIEwVisibilityChanged = false| mVisibleInsets = androID.graphics.Rect [ID=0x13364f00]| mWindow = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowID = null| mWindowleft = 0| mWindowToken = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowtop = 0| mWindowVisibility = 0* Instance of androID.vIEw.VIEwTreeObserver| mAlive = true| mOnComputeInternalinsetsListeners = null| mOnDrawListeners = null| mOnEnteranimationCompleteListeners = null| mOnGlobalFocusListeners = null| mOnGlobalLayoutListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x1315a300]| mOnPreDrawListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x13345760]| mOnScrollChangedListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x12fd3220]| mOntouchModechangelisteners = java.util.concurrent.copyOnWriteArrayList [ID=0x133a1420]| mOnWindowAttachListeners = null| mOnWindowFocusListeners = null| mOnwindowshownListeners = null| mwindowshown = false* Instance of androID.vIEw.VIEwTreeObserver$copyOnWriteArray| mAccess = androID.vIEw.VIEwTreeObserver$copyOnWriteArray$Access [ID=0x12fa1960]| mData = java.util.ArrayList [ID=0x12fd3240]| mDatacopy = null| mStart = false* Instance of java.util.ArrayList| static $staticOverhead = byte[] [ID=0x6fcffb29;length=16;size=32]| static MIN_CAPACITY_INCREMENT = 12| static serialVersionUID = 8683452581122892189| array = java.lang.Object[] [ID=0x13094a40;length=12]| size = 1| modCount = 1* Array of java.lang.Object[]| [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw [ID=0x12fa1950]| [1] = null| [2] = null| [3] = null| [4] = null| [5] = null| [6] = null| [7] = null| [8] = null| [9] = null| [10] = null| [
解决方法 在VIEw实际从窗口中分离之前,尝试更改删除侦听器的代码,如下所示:

[+++]

原因是,在从窗口分离后,getVIEwTreeObserver()返回一个不同的实例(“浮动树观察者”),因此您不会从添加它的同一对象中删除您的侦听器.

UPDATE

由于您正在使用子视图的VIEwTreeObserver,因此行为稍微复杂一点,一种可能的解决方案是将onAttachStatechangelistener添加到scrollVIEw并从那里添加/删除OnScrollChangedListener.

无论如何,有关泄漏的原因:getVIEwTreeObserver()在VIEw从窗口中分离后不会返回相同的实例.调用removeOnScrollChangedListener()可能无效,使原始的OnScrollChangedListener仍然附加到旧的VIEwTreeObserver,从而泄露了Context.

总结

以上是内存溢出为你收集整理的android – 了解ViewTreeObserver泄漏全部内容,希望文章能够帮你解决android – 了解ViewTreeObserver泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
android – 了解ViewTreeObserver泄漏_app_内存溢出

android – 了解ViewTreeObserver泄漏

android – 了解ViewTreeObserver泄漏,第1张

概述我正在使用LeakCanary 1.3.1-SNAPSHOT. 我发现有关ViewTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码: private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener; @Override protected void 我正在使用LeakCanary 1.3.1-SNAPSHOT.
我发现有关VIEwTreeObserver.OnScrollChangedListener设置的泄漏,我修复了它,如下面的代码:

private VIEwTreeObserver.OnScrollChangedListener scrollVIEwchangelistener;  @OverrIDe protected voID onFinishInflate() {      super.onFinishInflate();      ButterKnife.inject(this);      scrollVIEwchangelistener = new VIEwTreeObserver.OnScrollChangedListener() {      @OverrIDe public voID onScrollChanged() {        EventDetailsVIEw.this.onScrollChanged(scrollVIEw.getScrollY());      }    };      scrollVIEw.getVIEwTreeObserver()        .addOnScrollChangedListener(scrollVIEwchangelistener);  }  @OverrIDe public voID onDetachedFromWindow() {      super.onDetachedFromWindow();      scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);  }

然而,LeakCanary仍然将其报告为泄漏,任何想法为什么?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:* GC ROOT androID.vIEw.inputmethod.inputMethodManager.this
@OverrIDe public voID onDetachedFromWindow() {    scrollVIEw.getVIEwTreeObserver().removeOnScrollChangedListener(scrollVIEwchangelistener);    super.onDetachedFromWindow();}
(anonymous class extends com.androID.internal.vIEw.IinputMethodClIEnt$Stub)* references androID.vIEw.inputmethod.inputMethodManager.mCurRootVIEw* references com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.mAttachInfo* references androID.vIEw.VIEw$AttachInfo.mTreeObserver* references androID.vIEw.VIEwTreeObserver.mOnScrollChangedListeners* references androID.vIEw.VIEwTreeObserver$copyOnWriteArray.mData* references java.util.ArrayList.array* references array java.lang.Object[].[0]* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.this (anonymous class implements androID.vIEw.VIEwTreeObserver$OnScrollChangedListener)* references com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw.presenter* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c* Device: LGE Google Nexus 5 hammerhead* AndroID Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT* Durations: watch=5032ms,gc=165ms,heap dump=2932ms,analysis=29907ms* Details:* Instance of androID.vIEw.inputmethod.inputMethodManager| this = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mDescriptor = java.lang.String [ID=0x6f5e3f38]| mObject = -1601862176| mOwner = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]* Instance of androID.vIEw.inputmethod.inputMethodManager| static $staticOverhead = byte[] [ID=0x6fe25d29;length=240;size=256]| static CONTRol_START_INITIAL = 256| static CONTRol_WINDOW_FirsT = 4| static CONTRol_WINDOW_IS_TEXT_EDITOR = 2| static CONTRol_WINDOW_VIEW_HAS_FOCUS = 1| static DEBUG = false| static disPATCH_HANDLED = 1| static disPATCH_IN_PROGRESS = -1| static disPATCH_NOT_HANDLED = 0| static HIDE_IMPliCIT_ONLY = 1| static HIDE_NOT_ALWAYS = 2| static input_METHOD_NOT_RESPONDING_TIMEOUT = 2500| static MSG_BIND = 2| static MSG_DUMP = 1| static MSG_FLUSH_input_EVENT = 7| static MSG_SEND_input_EVENT = 5| static MSG_SET_ACTIVE = 4| static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9| static MSG_TIMEOUT_input_EVENT = 6| static MSG_UNBIND = 3| static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1| static PENDING_EVENT_COUNTER = java.lang.String [ID=0x6f5bb948]| static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0| static RESulT_HIDDEN = 3| static RESulT_SHOWN = 2| static RESulT_UNCHANGED_HIDDEN = 1| static RESulT_UNCHANGED_SHOWN = 0| static SHOW_FORCED = 2| static SHOW_IMPliCIT = 1| static TAG = java.lang.String [ID=0x6f5a76e0]| static sInstance = androID.vIEw.inputmethod.inputMethodManager [ID=0x130239c0]| mActive = true| mBindSequence = 1523| mClIEnt = androID.vIEw.inputmethod.inputMethodManager [ID=0x13112da0]| mCompletions = null| mCurChannel = androID.vIEw.inputChannel [ID=0x1304a850]| mCurID = java.lang.String [ID=0x1325dd80]| mCurMethod = com.androID.internal.vIEw.IinputMethodSession$Stub$Proxy [ID=0x1304a840]| mCurRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mCurSender = androID.vIEw.inputmethod.inputMethodManager$ImeinputEventSender [ID=0x12c72850]| mCurrentTextBoxAttribute = androID.vIEw.inputmethod.EditorInfo [ID=0x133036c0]| mCursorAnchorInfo = null| mCursorCandEnd = 0| mCursorCandStart = 0| mCursorRect = androID.graphics.Rect [ID=0x13112d40]| mCursorSelEnd = 0| mCursorSelStart = 0| mDummyinputConnection = androID.vIEw.inputmethod.BaseinputConnection [ID=0x13112dc0]| mFullscreenMode = false| mH = androID.vIEw.inputmethod.inputMethodManager$H [ID=0x13112de0]| mHasBeenInactive = false| mIinputContext = androID.vIEw.inputmethod.inputMethodManager$ControlledinputConnectionWrapper [ID=0x13113310]| mLastSentUserActionNotificationSequenceNumber = -1| mMainLooper = androID.os.Looper [ID=0x12c76be0]| mNextServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mNextUserActionNotificationSequenceNumber = 1| mPendingEventPool = androID.util.Pools$SimplePool [ID=0x13110fe0]| mPendingEvents = androID.util.SparseArray [ID=0x13112d80]| mRequestUpdateCursorAnchorInfoMonitorMode = 0| mServedConnecting = false| mServedinputConnection = null| mServedinputConnectionWrapper = null| mServedVIEw = com.couchsurfing.mobile.ui.drawer.DrawerVIEw [ID=0x131f8c00]| mService = com.androID.internal.vIEw.IinputMethodManager$Stub$Proxy [ID=0x13110fc0]| mTmpCursorRect = androID.graphics.Rect [ID=0x13112d20]| mVIEwToScreenMatrix = androID.graphics.Matrix [ID=0x13110fd0]| mVIEwtopleft = int[] [ID=0x13112d60;length=2;size=24]* Instance of com.androID.internal.policy.impl.PhoneWindow$DecorVIEw| mActionMode = null| mActionModePopup = null| mActionModeVIEw = null| mBackgroundFallback = com.androID.internal.Widget.BackgroundFallback [ID=0x12fdd8e0]| mBackgroundpadding = androID.graphics.Rect [ID=0x12ffd9a0]| mbarEnterExitDuration = 250| mChanging = false| mDefaultopacity = -1| mDownY = 0| mDrawingBounds = androID.graphics.Rect [ID=0x12ffd980]| mFeatureID = -1| mFrameOffsets = androID.graphics.Rect [ID=0x12ffd9e0]| mFramepadding = androID.graphics.Rect [ID=0x12ffd9c0]| mHIDeInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffdb00]| mLastBottomInset = 144| mLastHasBottomStableInset = true| mLastHastopStableInset = true| mLastRightInset = 0| mLasttopInset = 75| mLastwindowFlags = -2122252032| mMenuBackground = null| mNavigationcolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c70]| mNavigationGuard = null| mRootScrollY = 0| mShowActionModePopup = null| mShowInterpolator = androID.vIEw.animation.PathInterpolator [ID=0x12ffda60]| mStatuscolorVIEwState = com.androID.internal.policy.impl.PhoneWindow$colorVIEwState [ID=0x12ff2c40]| mStatusGuard = null| mWatchingForMenu = false| this = com.androID.internal.policy.impl.PhoneWindow [ID=0x12db9e00]| mForeground = null| mForegroundBoundsChanged = true| mForegroundG@R_301_6610@ty = 119| mForegroundInpadding = true| mForegroundpaddingBottom = 0| mForegroundpaddingleft = 0| mForegroundpaddingRight = 0| mForegroundpaddingtop = 0| mForegroundTintList = null| mForegroundTintMode = null| mHasForegroundTint = false| mHasForegroundTintMode = false| mMatchParentChildren = java.util.ArrayList [ID=0x12ffd960]| mMeasureAllChildren = false| mOverlayBounds = androID.graphics.Rect [ID=0x12ffd940]| mSelfBounds = androID.graphics.Rect [ID=0x12ffd920]| mAnimationListener = null| mCachePaint = null| mChildAcceptsDrag = false| mChildCountWithTransIEntState = 0| mChildtransformation = null| mChildren = androID.vIEw.VIEw[] [ID=0x130064c0;length=12]| mChildrenCount = 3| mCurrentDrag = null| mCurrentDragVIEw = null| mdisappearingChildren = null| mDragNotifIEdChildren = null| mFirstHoverTarget = null| mFirsttouchTarget = null| mFocused = androID.Widget.linearLayout [ID=0x12eac800]| mGroupFlags = 2375763| mHoveredSelf = false| mInvalIDateRegion = null| mInvalIDationtransformation = null| mLasttouchDownIndex = 0| mLasttouchDownTime = 137539724| mLasttouchDownX = 605.0| mLasttouchDownY = 1177.0| mLayoutAnimationController = null| mLayoutCalleDWhileSuppressed = false| mLayoutMode = 0| mLayoutTransitionListener = androID.vIEw.VIEwGroup [ID=0x12fdd850]| mLocalPoint = null| mnestedScrollAxes = 0| mOnHIErarchychangelistener = null| mPersistentDrawingCache = 2| mPreSortedChildren = null| mSuppressLayout = false| mTempPoint = float[] [ID=0x12c0a220;length=2;size=24]| mTransition = null| mTransitioningVIEws = null| mVisibilityChangingChildren = null| mAccessibilityCursorposition = -1| mAccessibilityDelegate = null| mAccessibilityTraversalAfterID = -1| mAccessibilityTraversalBeforeID = -1| mAccessibilityVIEwID = -1| mAnimator = null| mAttachInfo = androID.vIEw.VIEw$AttachInfo [ID=0x12c4fcc0]| mAttributes = null| mBackground = androID.graphics.drawable.colorDrawable [ID=0x13014f80]| mBackgroundRenderNode = androID.vIEw.RenderNode [ID=0x12c73740]| mBackgroundResource = 0| mBackgroundSizeChanged = false| mBackgroundTint = null| mBottom = 1920| mCachingFailed = false| mClipBounds = null| mContentDescription = null| mContext = com.couchsurfing.mobile.ui.MainActivity [ID=0x12db9c80]| mCurrentAnimation = null| mDrawableState = null| mDrawingCache = null| mDrawingCacheBackgroundcolor = 0| mfloatingTreeObserver = null| mGhostVIEw = null| mHasPerformedLongPress = false| mID = -1| minputEventConsistencyVerifIEr = null| mKeyedTags = null| mLabelForID = -1| mLastIsOpaque = true| mLayerPaint = null| mLayerType = 0| mLayoutInsets = null| mLayoutParams = androID.vIEw.WindowManager$LayoutParams [ID=0x12f1f7e0]| mleft = 0| mleftpaddingdefined = true| mListenerInfo = androID.vIEw.VIEw$ListenerInfo [ID=0x13109940]| mMatchIDPredicate = null| mMatchLabelForPredicate = null| mMeasureCache = androID.util.LongSparseLongArray [ID=0x13400120]| mMeasuredHeight = 1920| mMeasureDWIDth = 1080| mMinHeight = 0| mMinWIDth = 0| mnestedScrollingParent = null| mNextFocusDownID = -1| mNextFocusForwardID = -1| mNextFocusleftID = -1| mNextFocusRightID = -1| mNextFocusUpID = -1| moldHeightmeasureSpec = 1073743744| molDWIDthMeasureSpec = 1073742904| mOutlineProvIDer = androID.vIEw.VIEwOutlineProvIDer [ID=0x6fcd7240]| mOverScrollMode = 1| mOverlay = null| mpaddingBottom = 0| mpaddingleft = 0| mpaddingRight = 0| mpaddingtop = 0| mParent = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mPendingCheckForLongPress = null| mPendingCheckForTap = null| mPerformClick = null| mPrivateFlags = 25201976| mPrivateFlags2 = 1611867680| mPrivateFlags3 = 4| mRecreatedisplayList = false| mRenderNode = androID.vIEw.RenderNode [ID=0x12ffd880]| mResources = androID.content.res.Resources [ID=0x12c078e0]| mRight = 1080| mRightpaddingdefined = true| mScrollCache = null| mScrollX = 0| mScrollY = 0| mSendVIEwScrolledAccessibilityEvent = null| mSendVIEwStateChangedAccessibilityEvent = null| mSendingHoverAccessibilityEvents = false| mStateListAnimator = null| msystemUIVisibility = 0| mTag = null| mTempnestedScrollConsumed = null| mtop = 0| mtouchDelegate = null| mtouchSlop = 24| mtransformationInfo = androID.vIEw.VIEw$transformationInfo [ID=0x1349e7c0]| mTransIEntStateCount = 0| mTransitionname = null| mUnscaledDrawingCache = null| mUnsetpressedState = null| mUserpaddingBottom = 0| mUserpaddingEnd = -2147483648| mUserpaddingleft = 0| mUserpaddingLeftinitial = 0| mUserpaddingRight = 0| mUserpaddingRightinitial = 0| mUserpaddingStart = -2147483648| mVerticalScrollFactor = 0.0| mVerticalScrollbarposition = 0| mVIEwFlags = 402655360| mWindowAttachCount = 1* Instance of androID.vIEw.VIEw$AttachInfo| mAccessibilityFetchFlags = 0| mAccessibilityFocusDrawable = null| mAccessibilityWindowID = 2147483647| mApplicationScale = 1.0| mCanvas = null| mContentInsets = androID.graphics.Rect [ID=0x13364ee0]| mDeBUGLayout = false| mDisabledsystemUIVisibility = 0| mdisplay = androID.vIEw.display [ID=0x12f75b50]| mdisplayState = 2| mDrawingTime = 137551407| mForceReportNewAttributes = false| mGivenInternalinsets = androID.vIEw.VIEwTreeObserver$InternalinsetsInfo [ID=0x13364f40]| mGlobalsystemUIVisibility = 0| mHandler = androID.vIEw.VIEwRootImpl$VIEwRootHandler [ID=0x13364d00]| mHarDWareAccelerated = true| mHarDWareaccelerationRequested = true| mHarDWareRenderer = androID.vIEw.ThreadedRenderer [ID=0x13323dc0]| mHasNonEmptyGivenInternalinsets = false| mHassystemUIListeners = true| mHasWindowFocus = true| mHighContrastText = false| mIWindowID = null| mIgnoreDirtyState = false| mIntouchMode = true| mInvalIDateChildLocation = int[] [ID=0x13370060;length=2;size=24]| mKeepScreenOn = false| mKeydispatchState = androID.vIEw.KeyEvent$dispatcherState [ID=0x13364fc0]| mOverscanInsets = androID.graphics.Rect [ID=0x13364ec0]| mOverscanRequested = false| mPanelParentwindowToken = null| mPendingAnimatingRenderNodes = null| mPoint = androID.graphics.Point [ID=0x133582f0]| mRecomputeGlobalAttributes = false| mRootCallbacks = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mRootVIEw = com.androID.internal.policy.impl.PhoneWindow$DecorVIEw [ID=0x12eac000]| mScalingrequired = false| mScrollContainers = java.util.ArrayList [ID=0x13364fa0]| mSession = androID.vIEw.Iwindowsession$Stub$Proxy [ID=0x13358290]| mSetIgnoreDirtyState = true| mStableInsets = androID.graphics.Rect [ID=0x13364f20]| msystemUIVisibility = 0| mTempArrayList = java.util.ArrayList [ID=0x133701a0]| mTmpInvalRect = androID.graphics.Rect [ID=0x133700c0]| mTmpLocation = int[] [ID=0x13370080;length=2;size=24]| mTmpMatrix = androID.graphics.Matrix [ID=0x133582d0]| mTmpOutline = androID.graphics.Outline [ID=0x13370180]| mTmpRectList = java.util.ArrayList [ID=0x13370120]| mTmptransformLocation = float[] [ID=0x133700a0;length=2;size=24]| mTmptransformRect = androID.graphics.RectF [ID=0x133700e0]| mTmptransformRect1 = androID.graphics.RectF [ID=0x13370100]| mTmptransformation = androID.vIEw.animation.transformation [ID=0x13370140]| mtransparentLocation = int[] [ID=0x13370040;length=2;size=24]| mTreeObserver = androID.vIEw.VIEwTreeObserver [ID=0x133656c0]| mTurnOffWindowResizeAnim = false| mUnbuffereddispatchRequested = false| mUse32BitDrawingCache = true| mVIEwRequestingLayout = null| mVIEwRootImpl = androID.vIEw.VIEwRootImpl [ID=0x13313400]| mVIEwScrollChanged = false| mVIEwVisibilityChanged = false| mVisibleInsets = androID.graphics.Rect [ID=0x13364f00]| mWindow = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowID = null| mWindowleft = 0| mWindowToken = androID.vIEw.VIEwRootImpl$W [ID=0x13364e80]| mWindowtop = 0| mWindowVisibility = 0* Instance of androID.vIEw.VIEwTreeObserver| mAlive = true| mOnComputeInternalinsetsListeners = null| mOnDrawListeners = null| mOnEnteranimationCompleteListeners = null| mOnGlobalFocusListeners = null| mOnGlobalLayoutListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x1315a300]| mOnPreDrawListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x13345760]| mOnScrollChangedListeners = androID.vIEw.VIEwTreeObserver$copyOnWriteArray [ID=0x12fd3220]| mOntouchModechangelisteners = java.util.concurrent.copyOnWriteArrayList [ID=0x133a1420]| mOnWindowAttachListeners = null| mOnWindowFocusListeners = null| mOnwindowshownListeners = null| mwindowshown = false* Instance of androID.vIEw.VIEwTreeObserver$copyOnWriteArray| mAccess = androID.vIEw.VIEwTreeObserver$copyOnWriteArray$Access [ID=0x12fa1960]| mData = java.util.ArrayList [ID=0x12fd3240]| mDatacopy = null| mStart = false* Instance of java.util.ArrayList| static $staticOverhead = byte[] [ID=0x6fcffb29;length=16;size=32]| static MIN_CAPACITY_INCREMENT = 12| static serialVersionUID = 8683452581122892189| array = java.lang.Object[] [ID=0x13094a40;length=12]| size = 1| modCount = 1* Array of java.lang.Object[]| [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsVIEw [ID=0x12fa1950]| [1] = null| [2] = null| [3] = null| [4] = null| [5] = null| [6] = null| [7] = null| [8] = null| [9] = null| [10] = null| [
解决方法 在VIEw实际从窗口中分离之前,尝试更改删除侦听器的代码,如下所示:

原因是,在从窗口分离后,getVIEwTreeObserver()返回一个不同的实例(“浮动树观察者”),因此您不会从添加它的同一对象中删除您的侦听器.

UPDATE

由于您正在使用子视图的VIEwTreeObserver,因此行为稍微复杂一点,一种可能的解决方案是将onAttachStatechangelistener添加到scrollVIEw并从那里添加/删除OnScrollChangedListener.

无论如何,有关泄漏的原因:getVIEwTreeObserver()在VIEw从窗口中分离后不会返回相同的实例.调用removeOnScrollChangedListener()可能无效,使原始的OnScrollChangedListener仍然附加到旧的VIEwTreeObserver,从而泄露了Context.

总结

以上是内存溢出为你收集整理的android – 了解ViewTreeObserver泄漏全部内容,希望文章能够帮你解决android – 了解ViewTreeObserver泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1130149.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存