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

强颜欢笑 提交于 2021-02-10 05:41:05

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/47202589/if-i-start-a-firebase-trace-and-dont-ever-stop-it-will-it-cause-issues-on-andr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!