How to fix leak of SocketStream with service type set to VoIP?

倖福魔咒の 提交于 2019-12-11 07:19:58

问题


Xcode reporting SocketStream object is leaking after streams closing. Leak is reliably reproducible on iPhone, but not on Simulator or Mac.

Streams are created with CFStreamCreatePairWithSocketToCFHost, then used, closed and released, leaving another SocketStream every time.

I checked retain history in Instruments, and found out that every time read and write streams are closed SocketStream has retain count of 2. (my guess is these two retains are done in _CTServerConnecionCreateWithIdentifier from CoreTelephony)

Looking at how those streams are used I noticed it has network service type property set to VoIP (either CFStreamNetworkServiceTypeVoIP or NSStreamNetworkServiceTypeVoIP). I commented out those lines and the leaks are gone.

So, what's the proper way to close VoIP service streams? Can it be related somehow with VoIP deprecation?

来源:https://stackoverflow.com/questions/54045825/how-to-fix-leak-of-socketstream-with-service-type-set-to-voip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!