问题
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