简体   繁体   中英

Android Leaked Service Connection

I am using a JobIntent service to perform some operation. I am starting the Service from say Screen A.

After the service performs its work I am sending a callback from JobIntent Service to the Screen A. Then immediately the Screen A finishes itself and opens a new Screen say B.

I am able to notice that there is a log stating Leaked Service Connection. Below is the log

android.app.ServiceConnectionLeaked: Activity Package.ScreenA has leaked 
ServiceConnection Package.ServiceName$1@7a41f83 that was originally bound here

What does this error mean and is there any damage if this error continues? What can be done to prevent these kinds of errors?

Even though I am not sure but the service holds the context reference of the screenA which is why this might be happening?

Thanks in Advance!

Watch out for JobIntentService memory leak

Pass activity.getApplicationContext() — then static map indirectly will hold only Application object instance reference.

You can read this post this would be helpful for you.

https://medium.com/@luszczuk/watch-out-for-jobintentservice-memory-leak-828a629ab085

Credit: Michał Łuszczuk

在此处输入图片说明

@Rahulrr2602 Please use this chart to understand the limitations of each.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM