Open
Description
Hello everyone,
I've been using CombineExt extensively in my projects and found it incredibly valuable.
Recently, I encountered a memory leak issue with PassthroughRelay
. Upon replacing it with PassthroughSubject
, the retain cycle disappeared.
It appears that PassthroughRelay
fails to release its subscriptions upon receiving completion, as similarly described in this PR #85.
I've come up with a potential solution for this issue and confirmed its resolution in my project, but I'm not fully proficient with Combine. So, any comments or suggestions would be greatly appreciated.
Original Subscription
’s cancel
method:
func cancel() {
sink = nil
}
Solution:
// Call forceFinish() in Subscription’s cancel method.
// And add self.sink = nil in forceFinish method.
func forceFinish() {
self.sink?.shouldForwardCompletion = true
self.sink?.receive(completion: .finished)
self.sink = nil // added
}
func cancel() {
forceFinish() // replaced
}
Metadata
Metadata
Assignees
Labels
No labels