Skip to content

[SR-6881] Saving Data from URLSession to disk and NSCache causes double the memory #4260

@swift-ci

Description

@swift-ci
Contributor
Previous ID SR-6881
Radar https://bugreport.apple.com/web/?problemID=37082760
Original Reporter Jay18001 (JIRA User)
Type Bug

Attachment: Download

Environment

iOS 11.2, simulator and iPhone X

Xcode 9.2 (9C40b)

macOS 10.12.6 (16G1114)

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Leak
Assignee None
Priority Medium

md5: 2870ec4b8f985c3e6bf0c0086b771c40

Issue Description:

When a 10mb file is downloaded using URLSession and written to disk and saved to NSCache the memory goes up by 20mb.

Using the following causes the leak:

do {
     try data.write(to: fileUrl)
} catch {
     print(error)
}

However doing this does not cause the leak:

(data as NSData).write(to: fileUrl, atomically: true)

It happens every time the button is pressed in the attached example project

Activity

belkadan

belkadan commented on Feb 1, 2018

@belkadan

@swift-ci create

transferred this issue fromswiftlang/swifton May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @belkadan@swift-ci

        Issue actions

          [SR-6881] Saving Data from URLSession to disk and NSCache causes double the memory · Issue #4260 · swiftlang/swift-corelibs-foundation