0

I added the awesome LeakCanary library in my app and pretty soon I started to receive various reports for a leak generated by the FirebaseAuth Object that I use in the various activities.

Now my question is: is it a leak generated by the Firebase library itself or I should destroy the object in onDestroy (setting it to null for instance)?

Here is the report from LeakCanary and here is the heapdump

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

3

The answer is hidden in this line of the leak report:

* references com.ispimi.ispimi.DetailsFragment$4.this$0 (anonymous class implements com.firebase.client.ValueEventListener)

You need to make sure to remove any listener you added before your Activity is destroyed. Balance adding a listener with removing it. For example, if you added it in onCreate remove it in onDestroy. If you added it in onStart remove it in onStop and so on.

jonnydee
  • 1,311
  • 1
  • 7
  • 11