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

Android记录器是否在主线程上运行?如果是这样,记录大条目是否会对呈现UI产生性能影响? 最佳答案 你的第一个问题的答案取决于你在哪里调用Log,所以是的,它也运行在主线程上.您可以将日志放在任何您想要的位置.

由于它在您的控制台上打印日志,因此它肯定会影响您的应用程序性能

以下是docs的示例:

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

点赞