How to fix leak of SocketStream with service type

2019-07-29 12:39发布

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)

retains

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?

0条回答
登录 后发表回答