当我在 Android 设备监视器中分析我的应用程序时,我看到 Binder_1 Binder_2 Binder_3。当我不再需要这些线程以节省资源时,关闭这些线程的正确方法是什么?执行器有一个方法,shutdown,可以用来清理所有资源。安卓里有类似的东西吗?提前致谢!
最佳答案
What is the correct way to shut-down these threads when I no longer need them, to conserve resources
你不知道。这些是由框架管理的,而不是由您管理。
此外,由于绑定(bind)器线程通常会阻塞,除了一些少量的堆空间之外,我不清楚您希望节省哪些资源。
Over time it looks like the number of the number of these threads increases though which seems like a leak to me
制作一个重现行为的演示应用程序并 file an issue提供演示应用程序的源代码、重现问题的步骤以及您测试它的环境。如果您可以在官方 Android SDK 模拟器或 Nexus 系列设备上重现它,则可获得奖励积分。
Also if I don't need them is there a way to prevent them from being created?
我不知道你是如何确定是否需要它们的。毕竟,如果您的应用程序要运行,它将需要绑定(bind)器线程来执行此操作,以接收来自核心操作系统进程的传入通信(例如,广播 Intents
、startActivity()
请求)。同样,它们是由框架管理的,而不是由您管理。
关于android - 如何关闭 Android Binder 线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30876365/