Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address retain cycle with URLSessionClient #1366

Merged
merged 2 commits into from
Aug 20, 2020
Merged

Conversation

designatednerd
Copy link
Contributor

Addresses #1362 (at least partially) and #1292 (I believe in full).

The URLSessionClient object holding on to the URLSession and being its delegate creates a retain cycle. However, hanging on to the URLSession weakly doesn't work either, because it's just immediately deallocated:

Screen Shot 2020-08-20 at 1 00 22 PM

The somewhat inelegant solution is that you have to manually invalidate the URLSessionClient and stop holding on to the URLSession. Fortunately for most people, we can have HTTPNetworkClient do this without them having to think about it. This does mean if you're using URLSession outside HTTPNetworkClient you need to remember to do this, but for now I think that should be an edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant