如果我启动Firebase跟踪并且从不停止它?它会在Android上引起问题吗? [英] If I start a Firebase trace and don't ever stop it? Will it cause issues on Android?

查看:52
本文介绍了如果我启动Firebase跟踪并且从不停止它?它会在Android上引起问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Firebase性能监控SDK (在Android上,但同样在iOS上),对于一个特定的用例,很难知道是否已启动跟踪将永远停止.鉴于没有明显的方法来取消已经在运行的跟踪,我认为我会每次都启动它,然后最终仅在适当的情况下停止它.(否则保持原样).

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.

我还可能清除对跟踪的引用,并希望让GC对其进行扫描(前提是Firebase不会存储对每个正在运行的跟踪的引用)

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)

推荐答案

如果启动跟踪但从未停止,则该Trace对象将等待您停止它时,将泄漏少量内存.这可能没什么大不了的,但泄漏就是泄漏.当您要放弃跟踪时清除参考将允许对其进行垃圾收集.

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.

这篇关于如果我启动Firebase跟踪并且从不停止它?它会在Android上引起问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆