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

[6.0] Fix a memory leak in DownloadTaskManager and DataTaskManager #7416

Merged

Commits on Mar 20, 2024

  1. Fix a memory leak in DownloadTaskManager and DataTaskManager

    `DownloadTaskManager` had a strong reference to `URLSession`, which retained its delegate, which was the `DownloadTaskManager`. This formed a retain cycle.
    
    Make the reference from `URLSession` to the delegate weak and only keep `DownloadTaskManager` alive as long as `DownloadTask`s need it. This causes the `DownloadTaskManager` to be deallocated once nobody holds a reference to it anymore and all the tasks it manages are finished.
    
    Finally, we need to call `invalidate` on the `URLSession` to tell it that we’re done and that it should release its delegate (which is now the `WeakDownloadTaskManager`wrapper).
    
    rdar://125012584
    ahoppen committed Mar 20, 2024
    Copy the full SHA
    e9fabe1 View commit details
    Browse the repository at this point in the history