socket.io-client-swift
socket.io-client-swift copied to clipboard
Fix memory leak of URLSession in SocketEngine
SocketEngine retains an instance of URLSession, and this value is replaced in resetEngine(). But this instance of URLSession is leaked unless you call invalidateAndCancel(), which breaks the references between the session and its delegate and callbacks.
Note in contrast to other types in Foundation and UIKit, URLSession strongly retains its delegate. So the default configuration of SocketEngine still has a retain cycle since it sets itself as the delegate of the URLSession that it owns. Breaking this retain cycle requires user of the library to provide a custom URLSessionDelegate during configuration.