Skip to content

[SR-14194] URLSession shared - memory leak #4226

@swift-ci

Description

@swift-ci
Previous ID SR-14194
Radar rdar://problem/74274732
Original Reporter telcy (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

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.

import Foundation
DispatchQueue.global(qos: .default).async {
    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")!
    Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in
        URLSession.shared.dataTask(with: url) { _, _, _ in
            
        }.resume()
    }
    RunLoop.current.run()
}
RunLoop.main.run()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions