* com.a.b.presentation.view.fragment.mediaView.MediaViewFragment has leaked:
* GC ROOT android.app.ActivityThread$ApplicationThread.this$0
* references android.app.ActivityThread.mActivities
* references android.util.ArrayMap.mArray
* references array java.lang.Object[].[1]
* references android.app.ActivityThread$ActivityClientRecord.activity
* references com.a.b.presentation.view.activity.MainActivity.mFragments
* references android.support.v4.app.FragmentManagerImpl.mCreatedMenus
* references java.util.ArrayList.array
* references array java.lang.Object[].[0]
* references com.a.b.presentation.view.fragment.page.FeedPageFragment.mMediaViewFragment
* leaks com.a.b.presentation.view.fragment.mediaView.MediaViewFragment instance
* Reference Key: 7c4674d8-1f94-49c7-879d-78f4248baebd
* Device: Genymotion generic 11111 vbox86p
* Android Version: 5.1 API: 22 LeakCanary: 1.3.1
* Durations: watch=5037ms, gc=113ms, heap
Possible Cause:
android.support.v4.app.FragmentManagerImpl holds an ArrayList<Fragment> mCreatedMenus to keep track of which fragment has setHasOptionsMenu(true) called and will call onDestroyOptionsMenu() for them in next dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater) and replace with the new ArrayList<Fragment> newMenus.
I suspect that removing a fragment using transaction will not cause the fragment to be removed from mCreatedMenus thus causing the leak.
Hi,
I'm seeing this one also.
And some others related to other FragmentManagerImpl "ArrayList
Hi.
I have the same problem. In my case it is leaking because i have a custom enter animation and the TransitionState is keeping a reference i don't know where.
I see no solution so far.
* com.feeln.android.activity.MovieDetailActivity has leaked:
* GC ROOT android.app.ActivityThread$ApplicationThread.this$0
* references android.app.ActivityThread.mActivities
* references android.util.ArrayMap.mArray
* references array java.lang.Object[].[1]
* references android.app.ActivityThread$ActivityClientRecord.activity
* references com.feeln.android.activity.MovieDetailActivity.mActivityTransitionState
* references android.app.ActivityTransitionState.mEnterTransitionCoordinator
* references android.app.EnterTransitionCoordinator.mEnterViewsTransition
* references android.transition.TransitionSet.mParent
* references android.transition.TransitionSet.mListeners
* references java.util.ArrayList.array
* references array java.lang.Object[].[1]
* references android.transition.TransitionManager$MultiListener$1.val$runningTransitions (anonymous class extends android.transition.Transition$TransitionListenerAdapter)
* references android.util.ArrayMap.mArray
* references array java.lang.Object[].[2]
* references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
* leaks com.feeln.android.activity.MovieDetailActivity instance
* Reference Key: af2b6234-297e-4bab-96e9-02f1c4bca171
* Device: LGE google Nexus 5 hammerhead
* Android Version: 5.1.1 API: 22 LeakCanary: 1.3.1
I'm getting a similar leak, did anyone ever find a resolution?
* GC ROOT android.app.ActivityThread$ApplicationThread.this$0
* references android.app.ActivityThread.mActivities
* references android.util.ArrayMap.mArray
* references array java.lang.Object[].[1]
* references android.app.ActivityThread$ActivityClientRecord.activity
* references com.app.SomeActivity.mFragments
* references android.support.v4.app.FragmentController.mHost
* references android.support.v4.app.FragmentActivity$HostCallbacks.mFragmentManager
* references android.support.v4.app.FragmentManagerImpl.mCreatedMenus
* references java.util.ArrayList.array
* references array java.lang.Object[].[0]
* leaks com.app.fragments.SomeFragment instance
Mark. The same problem.
Thank you for your report, it looks like this might be a leak in the Android SDK.
Please read the following entry in our FAQ: Can a leak be caused by the Android SDK?.
We don't have enough time to do the investigative work on this type of issue, so I will close this issue for now. We'll happily take contributions to AndroidExcludedRefs.java, if the leak is demonstrated and the fix provided to AOSP.
I'm seeing this one too. Did anyone determine if this was a leak in the SDK?
It is a leak in the Android SDK: https://code.google.com/p/android/issues/detail?id=227136.
And it has a workaround.
@pyricau as @stephanenicolas said its an SDK leak please include it in AndroidExcludedRefs.java.
Please re-open the issue.
It is a leak in the Android SDK: https://code.google.com/p/android/issues/detail?id=227136.
And it has a workaround.
This was two years ago. @Guneetgstar are you still seeing this leak? If yes can you provide a leaktrace from LeakCanary 2.0, as well as the Android X or support library version ? If not we'll have to close this.
@pyricau Here is the leak trace from Nexus 5 API v6.0.1, using Android X 1.1.0 and LeakCanary 2.0-beta-3 :-
ApplicationLeak(className=com.colevit.furmate.module.home.fragment.sub.DocumentsFragment, leakTrace=
β¬
ββ android.app.ActivityThread
β Leaking: NO (ActivityThreadβ is not leaking and a class is never leaking)
β GC Root: System class
β β static ActivityThread.sCurrentActivityThread
ββ android.app.ActivityThread
β Leaking: NO (ArrayMapβ is not leaking)
β β ActivityThread.mActivities
ββ android.util.ArrayMap
β Leaking: NO (Object[]β is not leaking)
β β ArrayMap.mArray
ββ java.lang.Object[]
β Leaking: NO (ActivityThread$ActivityClientRecordβ is not leaking)
β β array Object[].[1]
ββ android.app.ActivityThread$ActivityClientRecord
β Leaking: NO (HomeActivityβ is not leaking)
β β ActivityThread$ActivityClientRecord.activity
ββ com.colevit.furmate.module.home.HomeActivity
β Leaking: NO (Activity#mDestroyed is false)
β β HomeActivity.manager
β ~~~~~~~
ββ androidx.fragment.app.FragmentManagerImpl
β Leaking: UNKNOWN
β β FragmentManagerImpl.mCreatedMenus
β ~~~~~~~~~~~~~
ββ java.util.ArrayList
β Leaking: UNKNOWN
β β ArrayList.array
β ~~~~~
ββ java.lang.Object[]
β Leaking: UNKNOWN
β β array Object[].[0]
β ~~~
β°β com.colevit.furmate.module.home.fragment.sub.DocumentsFragment
β Leaking: YES (Fragment#mFragmentManager is null and ObjectWatcher was watching this)
β key = 4c62fa54-21bc-4c44-af9d-cca289be67a6
β watchDurationMillis = 164034
β retainedDurationMillis = 159034
, retainedHeapByteSize=1570)
Cool. Looks like this is also well documented on stack overflow: https://stackoverflow.com/questions/44674696/fragmentmanagerv4-not-removing-fragments-from-mcreatedmenus
Any tips on how to ignore this leak in Leak Canary 2.0? I tried the following... but no dice.
AndroidReferenceMatchers.instanceFieldLeak(
className = "androidx.fragment.app.FragmentManagerImpl",
fieldName = "mCreatedMenus",
description = "FragmentManager not removing items from mCreatedMenus."
)
Just guessing but usually, you should put the reference to the thing that
leaks to null.
And usually, because there is no API, you have to use reflection...
Le ven. 27 dΓ©c. 2019 19 h 50, Nicholas Pike notifications@github.com a
Γ©crit :
Any tips on how to ignore this leak in Leak Canary 2.0? I tried the
following... but no dice.AndroidReferenceMatchers.instanceFieldLeak(
className = "androidx.fragment.app.FragmentManagerImpl",
fieldName = "mCreatedMenus",
description = "FragmentManager not removing items from mCreatedMenus."
)β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/leakcanary/issues/185?email_source=notifications&email_token=AAN7PXK3RQTFF74S34AZ7LTQ2ZE7HA5CNFSM4BIP7F7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHXTMPI#issuecomment-569325117,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAN7PXMO3UF7PIHVFEXATWLQ2ZE7HANCNFSM4BIP7F7A
.
@npike this looks like the right configuration. Can you share the code you wrote to add that to the configuration? Maybe something is wrong there (I want to know to see how the documentation could be improved).
Also, feel free to contribute this back :)
Most helpful comment
@pyricau Here is the leak trace from Nexus 5 API v6.0.1, using Android X 1.1.0 and LeakCanary 2.0-beta-3 :-