chaychan / BottomBarLayout

(一个轻量级的底部导航控件)A simple and lightly widget to accomplish bottom Navigation,可设置未读数、提示点、提示消息
954 stars 193 forks source link

有内存泄漏的问题 #24

Closed liaocao closed 5 years ago

liaocao commented 5 years ago

这个库本身写的非常贴心,属性都很全,但是用到我的项目里超过2个Fragment就报内存泄漏的问题,我换回TabLayout就正常了,好可惜

chaychan commented 5 years ago

@liaocao 麻烦提供下内存泄露检测的截图

liaocao commented 5 years ago

这些报错内容行不行,我是用leakcanary这个库检测出来的

In com.kq.producthp:1.0:1. com.kq.fragment.ContactFragment has leaked: static ActivityCollector.activities ↳ ArrayList.array ↳ array Object[].[0] ↳ MainNewActivity.!(mFragmentList)! ↳ ArrayList.!(array)! ↳ array Object[].!([0])! ↳ ContactFragment Reference Key: a43598ae-0cb5-4e59-9bd7-fd04ddd46346 Device: Meizu Meizu MX4 meizu_mx4 Android Version: 5.1 API: 22 LeakCanary: 1.6.1 26145bf Durations: watch=5003ms, gc=164ms, heap dump=2929ms, analysis=21271ms Details: Class com.kq.tools.ActivityCollector | static $staticOverhead = byte[8]@317782785 (0x12f0fb01) | static activities = java.util.ArrayList@317995520 (0x12f43a00) Instance of java.util.ArrayList | static $staticOverhead = byte[16]@1897204169 (0x711509c9) | static MIN_CAPACITY_INCREMENT = 12 | static serialVersionUID = 8683452581122892189 | array = java.lang.Object[12]@317962880 (0x12f3ba80) | size = 1 | modCount = 5 Array of java.lang.Object[] | [0] = com.kq.MainNewActivity@316131328 (0x12d7c800) | [1] = null | [2] = null | [3] = null | [4] = null | [5] = null | [6] = null | [7] = null | [8] = null | [9] = null | [10] = null | [11] = null Instance of com.kq.MainNewActivity | mBottomBarLayout = com.chaychan.library.BottomBarLayout@314685440 (0x12c1b800) | mFragmentList = java.util.ArrayList@317694720 (0x12efa300) | mViewPager = android.support.v4.view.ViewPager@314680320 (0x12c1a400) | mDelegate = android.support.v7.app.AppCompatDelegateImplV14@314788864 (0x12c34c00) | mResources = null | mThemeId = 2131689670 | mCreated = true | mFragments = android.support.v4.app.FragmentController@317406832 (0x12eb3e70) | mHandler = android.support.v4.app.FragmentActivity$1@317694624 (0x12efa2a0) | mLoaderManager = null | mNextCandidateRequestIndex = 0 | mPendingFragmentActivityResults = android.support.v4.util.SparseArrayCompat@317697376 (0x12efad60) | mReallyStopped = false | mRequestedPermissionsFromFragment = false | mResumed = true | mRetaining = false | mStopped = false | mViewModelStore = null | mStartedActivityFromFragment = false | mStartedIntentSenderFromFragment = false | mExtraDataMap = android.support.v4.util.SimpleArrayMap@317694496 (0x12efa220) | mLifecycleRegistry = android.arch.lifecycle.LifecycleRegistry@317650832 (0x12eef790) | mAccessControlManager = null | mActionBar = null | mActionBarToTop = false | mActivityInfo = android.content.pm.ActivityInfo@317710464 (0x12efe080) | mActivityTransitionState = android.app.ActivityTransitionState@317674560 (0x12ef5440) | mAllLoaderManagers = android.util.ArrayMap@318005312 (0x12f46040) | mApplication = com.kq.MyApplication@316044000 (0x12d672e0) | mCalled = true | mChangeCanvasToTranslucent = false | mChangingConfigurations = false | mCheckedForLoaderManager = true | mComponent = android.content.ComponentName@316465632 (0x12dce1e0) | mConfigChangeFlags = 0 | mContainer = android.app.Activity$1@317406752 (0x12eb3e20) | mCurrentConfig = android.content.res.Configuration@317427152 (0x12eb8dd0) | mDecor = com.android.internal.policy.impl.PhoneWindow$DecorView@314651648 (0x12c13400) | mDefaultKeyMode = 0 | mDefaultKeySsb = null | mDestroyed = false | mDoReportFullyDrawn = false | mEmbeddedID = null | mEnableDefaultActionBarUp = false | mEnterTransitionListener = android.app.SharedElementCallback$1@1897021392 (0x71123fd0) | mExitTransitionListener = android.app.SharedElementCallback$1@1897021392 (0x71123fd0) | mFinished = false | mFragments = android.app.FragmentManagerImpl@317426928 (0x12eb8cf0) | mHandler = android.os.Handler@317694464 (0x12efa200) | mIdent = 791638776 | mInject = android.app.Activity$TintBarInject@317421408 (0x12eb7760) | mInstanceTracker = android.os.StrictMode$InstanceTracker@317406768 (0x12eb3e30) | mInstrumentation = android.app.Instrumentation@315010272 (0x12c6ace0) | mIntent = android.content.Intent@317702208 (0x12efc040) | mLastNonConfigurationInstances = null | mLoaderManager = null | mLoadersStarted = true | mMainThread = android.app.ActivityThread@314835520 (0x12c40240) | mManagedCursors = java.util.ArrayList@317694400 (0x12efa1c0) | mManagedDialogs = null | mMenuInflater = null | mParent = null | mReferrer = "com.kq.producthp" | mResultCode = 0 | mResultData = null | mResumed = true | mSearchManager = null | mStartedActivity = false | mStopped = false | mTemporaryPause = false | mTitle = "精准扶贫2.0" | mTitleColor = 0 | mTitleReady = true | mToken = android.os.BinderProxy@316584512 (0x12deb240) | mTranslucentCallback = null | mUiThread = java.lang.Thread@1965391872 (0x75258000) | mVisibleBehind = false | mVisibleFromClient = true | mVisibleFromServer = true | mVoiceInteractor = null | mWindow = com.android.internal.policy.impl.PhoneWindow@316672720 (0x12e00ad0) | mWindowAdded = true | mWindowManager = android.view.WindowManagerImpl@317695136 (0x12efa4a0) | scrollCallback = null | mInflater = com.android.internal.policy.impl.PhoneLayoutInflater@317651168 (0x12eef8e0) | mOverrideConfiguration = null | mResources = android.content.res.Resources@314591824 (0x12c04a50) | mTheme = android.content.res.Resources$Theme@317695168 (0x12efa4c0) | mThemeResource = 2131689670 | mBase = android.app.ContextImpl@317201120 (0x12e81ae0) | mColorThemeCacheMap = java.util.HashMap@317650736 (0x12eef730) Instance of java.util.ArrayList | static $staticOverhead = byte[16]@1897204169 (0x711509c9) | static MIN_CAPACITY_INCREMENT = 12 | static serialVersionUID = 8683452581122892189 | array = java.lang.Object[12]@317962944 (0x12f3bac0) | size = 3 | modCount = 3 Array of java.lang.Object[] | [0] = com.kq.fragment.ContactFragment@314938128 (0x12c59310) | [1] = com.kq.fragment.ApplyFragment@314856192 (0x12c45300) | [2] = com.kq.fragment.MyFragment@317679616 (0x12ef6800) | [3] = null | [4] = null | [5] = null | [6] = null | [7] = null | [8] = null | [9] = null | [10] = null | [11] = null Instance of com.kq.fragment.ContactFragment | static isCanCallPhone = false | static REQUEST_CALL_PHONE = 1 | static $staticOverhead = byte[16]@316338177 (0x12daf001) | decoration = com.kq.contacts.CustomItemDecoration@321738304 (0x132d5640) | handler = com.kq.fragment.ContactFragment$1@317995968 (0x12f43bc0) | layoutManager = android.support.v7.widget.LinearLayoutManager@321364160 (0x1327a0c0) | mAdapter = com.kq.contacts.ContactAdapter@321733488 (0x132d4370) | nameList = java.util.ArrayList@317995936 (0x12f43ba0) | rl_recycle_view = android.support.v7.widget.RecyclerView@321428480 (0x13289c00) | side_bar = com.kq.contacts.SideBar@316266624 (0x12d9d880) | context = com.kq.MainNewActivity@316131328 (0x12d7c800) | isShow = false | mCommonToolbar = android.support.v7.widget.Toolbar@321423360 (0x13288800) | titleTv = android.support.v7.widget.AppCompatTextView@321424384 (0x13288c00) | mAdded = false | mAnimationInfo = null | mArguments = null | mBackStackNesting = 0 | mCalled = true | mChildFragmentManager = null | mChildNonConfig = null | mContainer = null | mContainerId = 0 | mDeferStart = false | mDetached = false | mFragmentId = 0 | mFragmentManager = null | mFromLayout = false | mHasMenu = false | mHidden = false | mHiddenChanged = false | mHost = null | mInLayout = false | mIndex = -1 | mInnerView = null | mIsCreated = false | mIsNewlyAdded = false | mLayoutInflater = null | mLifecycleRegistry = android.arch.lifecycle.LifecycleRegistry@317987232 (0x12f419a0) | mLoaderManager = null | mMenuVisible = false | mParentFragment = null | mPerformedCreateView = false | mPostponedAlpha = 0.0 | mRemoving = false | mRestored = false | mRetainInstance = false | mRetaining = false | mSavedFragmentState = null | mSavedUserVisibleHint = null | mSavedViewState = android.util.SparseArray@317614080 (0x12ee6800) | mState = 0 | mTag = null | mTarget = null | mTargetIndex = -1 | mTargetRequestCode = 0 | mUserVisibleHint = false | mView = null | mViewModelStore = null | mWho = null * Excluded Refs: | Field: android.os.Message.obj | Field: android.os.Message.next | Field: android.os.Message.target | Field: android.view.inputmethod.InputMethodManager.mNextServedView | Field: android.view.inputmethod.InputMethodManager.mServedView | Field: android.view.inputmethod.InputMethodManager.mServedInputConnection | Field: android.view.inputmethod.InputMethodManager.mCurRootView | Field: android.animation.LayoutTransition$1.val$parent | Field: android.view.textservice.SpellCheckerSession$1.this$0 | Field: android.widget.SpellChecker$1.this$0 | Field: android.support.v7.internal.widget.ActivityChooserModel.mActivityChoserModelPolicy | Field: android.widget.ActivityChooserModel.mActivityChoserModelPolicy | Field: android.accounts.AccountManager$AmsTask$Response.this$1 | Field: android.media.MediaScannerConnection.mContext | Field: android.os.UserManager.mContext | Field: android.media.AudioManager$1.this$0 | Field: android.widget.Editor$Blink.this$0 | Field: android.net.ConnectivityManager.sInstance | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always) | Static field: android.text.TextLine.sCached | Static field: android.app.Instrumentation.mRecommendActivity | 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)

chaychan commented 5 years ago

@liaocao 请问何以看出BottomBarLayout出现内存泄露呢

liaocao commented 5 years ago

我水平不够,找不到原因,就是换了tablayout就正常了