-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible memory leak in ActivityRecyclerPool with Dagger Hilt #1025
Comments
Facing the same problem as well with Hilt's FragmentContextWrapper, however I'm not sure if that's Epoxy's fault or Hilt's. Maybe If Hilt somehow can provide a way to disable the usage of that wrapper since not all views needs to be injected, that would solve the problem. |
Clearing the adapter in
|
From google/dagger#2070
The point of EpoxyRecyclerView's shared view pool is to reuse views across all fragments in an Activity as an optimization. Hilt's design breaks this, as they are make a bad assumption (which they recognize is an issue). Besides the work around of inflating your views with the activity inflater, you can also disable Epoxy's context wide view recycling - If you care about this it may also be helpful for you to weigh in on the Hilt issue (google/dagger#2070) and encourage them to fix it on their side. |
@elihart can you please tell me how to disable Epoxy's context wide view recycling - EpoxyRecyclerView#shouldShareViewPoolAcrossContext??? |
I've just migrated one of our apps to Dagger Hilt and now LeakCanary 2 is finding leaks in our fragments that use Epoxy.
The issue seems very similar to #886, but instead of a
ContextWrapper
Hilt gives us anFragmentContextWrapper
instead. See here: https://github.com/google/dagger/blob/71509b841b30909ddf6cb36ed366d4a609d84071/java/dagger/hilt/android/internal/managers/ViewComponentManager.java#L169LeakCanary trace
This happens in both the latest 4.0 beta & latest stable version of Epoxy
One way I've found to fix it is using a different context when inflating the view.
Instead of using the supplied LayoutInflater, fetching it from the activity seems to solve the issue:
The text was updated successfully, but these errors were encountered: