Remove ServiceBrowser as a listener from Zeroconf when the service finishes#20
Remove ServiceBrowser as a listener from Zeroconf when the service finishes#20morpav wants to merge 1 commit into
Conversation
…nishes Not removing the service causes that it cannot be collected by garbage collector when cancelled (other objects transitively as well).
3 similar comments
|
@morpav Sorry for the delay, thanks for this patch. Can you provide some additional information regarding what exactly cannot be collected and when? |
|
Thanks so much for the pull request. I made several improvements to ZC() shutdown, including incorporating these changes, before I had access to this repo. As of now I believe the functionality from this PR has been incorporated, and I unfortunately have no good way to merge the PR to give you credit for the change, so I am going to close it. If you think this an error, or an otherwise bad idea, please comment back. Thanks again for your help. |
|
@jstasiak It is really long time ago, but if I remember correctly, the class updated in the PR (ServiceBrowser) registered itself into an externally provided "zc" instance in constructor. But it never did the opposite when being cancelled. So all resources acquired/referenced by the ServiceBrowser instance was not freed transitively as well. So a kind of memory leak occurred. @stephenrauch The PR was super simple so I'm sure you did it right :) Thank you. |
Not removing the service causes that it cannot be collected by garbage collector when the service is cancelled. Other objects can be blocked transitively as well, e.g. listener passed to ServiceBrowser's init etc.