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/