Search code examples
androidandroid-fragmentsmemory-leaksleakcanaryresource-leak

What could be the leak in this leak canary report?


I am trying to find out the exact reason for this leak but still not able to figure out why this leak has happened as ForeignMoviesFragment instance is not hold anywhere. Need help.

Below is the screenshot enter image description here


Solution

  • ForeignMoviesFragment$1 is an anonymous inner class within ForeignMoviesFragment. Non-static inner classes have an implicit reference to the outer-class. If the anonymous class is passed & held by a class whose lifecycle is greater than the Fragment's, then it will leak