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
[SR-14194] URLSession shared - memory leak #4226
Comments
@swift-ci create |
Comment by Jascha Burmeister (JIRA) Another example. Memory is growing over time and only gets freed after completing the loop. import Foundation
let url = URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/Italian_States-Piacenza_1626_2_Doppie.jpg/2880px-Italian_States-Piacenza_1626_2_Doppie.jpg")!
for i in 1...200 {
autoreleasepool {
print(i)
URLSession.shared.dataTask(with: url) { _, _, _ in
}.resume()
sleep(1)
}
}
RunLoop.main.run() |
Comment by Jascha Burmeister (JIRA) I decided to rewrite my application in Rust and surprisingly had the same memory issue. Same code runs fine on Linux. There seems to be a memory leak down the network request stack.
|
Here's the message I received:
|
From what I understand based on the discussion in this reddit thread, the above doesn't quite answer how to fix the leak, since there is no delegate in the example. https://www.reddit.com/r/swift/comments/ms5orj/possibly_memory_leak_in_macos_network_request/ However, since this issue is related to the networking stack and not the open source toolchain (Swift, LLDB, SourceKit etc.), and a separate Feedback has been filed (FB9076036), I'm going to leave this as Resolved instead of reopening it. |
Additional Detail from JIRA
md5: 39fc7d661ef45654ab81ab331c820df6
Issue Description:
I have a scheduled timer requesting a url every x seconds. For some reason URLSession.shared fills the memory slowly over time and never frees it.
The text was updated successfully, but these errors were encountered: