android - android 记录器是否在主线程上运行?

标签 android performance logging

Android 记录器是否在主线程上运行?如果是这样,记录大条目是否会对呈现 UI 的性能产生影响?

最佳答案

第一个问题的答案取决于您从哪里调用 Log 所以是的,它也在主线程上运行。您可以将日志放在任何您想要的地方。

由于它将日志打印到您的控制台中,因此它肯定会影响您的应用性能

这是来自文档的示例:

Log.v(TAG, "index=" + i);

Don't forget that when you make a call like that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object. Realistically, there is also another buffer allocation and copy, and even more pressure on the gc. That means that if your log message is filtered out, you might be doing significant work and incurring significant overhead.

阅读Docs

关于android - android 记录器是否在主线程上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48759034/

相关文章:

android - 第二个按钮不起作用,但第一个可以

android - 游戏商店 : This app may not be optimised for your device

Android:将捕获的视频设置为动态壁纸

java - 单击按钮时应用程序崩溃

c++ - 在 C 中导航数组(性能)?

performance - 就地修改数组的函数意外减速

performance - 分散数组中的重复项

python - 如何在 apache 下从 mod_python 写入日志?

java - Grails日志配置正在劫持外部日志配置,如何阻止它?

logging - Logstash:GROK 导致 `thread watchdog timeout`