leakcanary
How to use Leak Canary
The nice thing about leak canary is how automated it works. By default, it already “watches” for activities that are not being properly GCed. So out of the box, if any activity is leaking you should receive the notification. On my project I’ve added an extra method on the Application like this: public class ExampleApplication … Read more
Could Navigation Arch Component create a false positive memory leak?
That’s how Fragments on the back stack work (and Navigation just uses the existing Fragment APIs): the Fragment’s view is destroyed, but the Fragment itself is not destroyed – they are kept in the CREATED state until you hit the back button and return to the Fragment (after which onCreateView() will be called again and … Read more
Leak canary, Recyclerview leaking mAdapter
If the adapter lives any longer than the RecyclerView does, you’ve got to clear the adapter reference in onDestroyView: @Override public void onDestroyView() { recyclerView.setAdapter(null); super.onDestroyView(); } Otherwise the adapter is going to hold a reference to the RecyclerView which should have already gone out of memory. Special note prior to androidx.fragment:fragment:1.3.0: If the screen … Read more