Search code examples
androidfirebasefirebase-performance

If I start a Firebase trace and don't ever stop it? Will it cause issues on Android?


I'm using Firebase Performance Monitoring SDK (on Android, but will also on iOS) and for one particular use case it's hard to know whether a started Trace will ever be stopped. And given there is no apparent way how to cancel an already running trace, I figured I'd just start it every single time and then eventually stop it only under the right circumstances. (and leave intact otherwise).

Shall I expect issues? I figured the trace would not be logged if not stopped (that's what I need), but I'm scared of memory leaks and also some general resource waste.

I could also potentially clear the reference to the trace and hopefully let GC sweep it (provided Firebase doesn't store a reference to each running Trace)


Solution

  • If you start a trace but never stop it, a very small amount of memory will be leaked for that Trace object as it waits for you to stop it. It's probably not a big deal, but a leak is a leak. Clearing the reference when you would like to abandon the trace will allow it to be garbage collected.