grpc-swift
grpc-swift copied to clipboard
ConnectivityStateDelegate should be weak
Describe the bug
The delegate property of the ConnectivityStateMonitor should be weak and is currently causing values to be retained longer than necessary because of it.
https://github.com/grpc/grpc-swift/blob/988ee3fcc98598c39db8385e92d1c8bb4e3c28a7/Sources/GRPC/ConnectivityState.swift#L76
To reproduce
Steps to reproduce the bug you've found:
- Create a channel and add a connectivity delegate via
withConnectivityStateDelegatemethod - Nil out the owner of the channel and observe that it is still in memory after being torn down.
Expected behaviour
Owner of channel (and delegate of connectivity monitor) should be torn down when the owner is torn down.
grpc-swift uses an explicit shutdown mechanism: it does not shut its resources down on deinit. This is an intentional design pattern: you must close your channel explicitly.