Find out leak problems in Looper or HandlerThread

I used some handlers such as

new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { try{ Messages.onAcknowledgeReceived(); }catch(Exception e){ e.printStackTrace(); } } }); 

Runs every 15 seconds, and sometimes it triggers some warnings, for example

  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] 

Are there any bugs in my programming approach? I still don't understand where the leak in this bit of code is.

+6
source share

Source: https://habr.com/ru/post/979765/


All Articles