找出Looper或HandlerThread中的泄漏问题

时间:2014-12-17 08:57:45

标签: android android-handler android-looper

我使用了一些像

这样的处理程序
           new Handler(Looper.getMainLooper()).post(new Runnable() {

            @Override
            public void run() {
                try{
                    Messages.onAcknowledgeReceived();                                       

                }catch(Exception e){
                    e.printStackTrace();
                }

                }
            }); 

它每15秒执行一次,有时它开始抛出一些警告,如

 The Looper class instance count has over a limit(100). There should be some leakage of Looper or HandlerThread.
 12-16 12:16:11.357: E/Looper(4647): Looper class instance count = 221
 12-16 12:16:11.357: E/Looper(4647): Current Thread Name: IntentService[AppService]
 12-16 12:16:12.316: E/Looper(4647): WARNING: The Looper class instance count has over a   limit(100). There should be some leakage of Looper or HandlerThread.
 12-16 12:16:12.318: E/Looper(4647): Looper class instance count = 222
 12-16 12:16:12.318: E/Looper(4647): Current Thread Name: IntentService[GCMIntentService-419284807656-203]

我的编程方法有什么问题吗?我仍然不明白这段代码中的泄漏在哪里。

0 个答案:

没有答案