Closed johnno1962 closed 6 years ago
This appears to be a recent regression (or is due to being a dev build?):
johnno@Ubuntu16:\~/swift-android-samples/swifthello$ \~/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-13-a-ubuntu16.04/usr/bin/swift -O hello.swift
Done 150072
Done 150340
Done 150604
Done 150868
Done 151132
Done 151916
Done 152176
Done 152440
Done 152704
^C
johnno@Ubuntu16:\~/swift-android-samples/swifthello$ \~/swift-3.1.1-RELEASE-ubuntu16.04/usr/bin/swift -O hello.swift
Done 103084
Done 103600
Done 103880
Done 103880
Done 103880
Done 103880
Done 103880
Done 104144
Done 104144
Done 104144
Done 104144
Seems to be a regression looking back at the 3.1 development snapshot (KB not increasing):
johnno@Ubuntu16:\~/swift-android-samples/swifthello$ \~/swift-3.1-DEVELOPMENT-SNAPSHOT-2017-06-14-a-ubuntu16.04/usr/bin/swift -O hello.swift
Done 133316
Done 134108
Done 134112
Done 134112
Done 134376
Done 134376
Done 134376
Done 134376
Done 134376
Done 134376
Done 134376
Done 134904
Done 134904
Done 134904
^C
Graphing memory use, even Swift 3.1 showed continually increasing memory use though increasing at a slower rate.
@phausler, an autorelease pool thing, maybe?
My guess is the differential of leaks is more pronounced because the swift implementation of NSURLSession and other Foundation classes are not nearly as optimized as the objective-c versions. That being said; if they are both leaking then we have achieved parity. It would be useful to build this example on Darwin based of swift-corelibs-foundation and run it in instruments. (you can attach Instruments to the TestFoundation target and run this code before the test main).
It was the much greater leakage with Swift4 toolchains (on Linux) I was trying to point out (see the first comment.)
PR raised which seems to fix this problem on Linux as well as Android https://github.com/apple/swift-corelibs-foundation/pull/1195
Environment
Linux 16.04, Swift built from master 2017-07-16Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Bug, 4.0Regression, Linux | |Assignee | None | |Priority | Medium | md5: e055efa0a71c9a5f3c321efec7fe7e4eIssue Description:
Hi, I’ve been looking at the Linux variant or Swift and found what could be a memory leak when using URLSession. If I place the code below in a file and execute using the REPL, the recorded memory continually increases on Linux by about roughly the amount of the Data received from the website. Memory also increases indefinitely on macOS but the effect is not quite so pronounced. This seems to be a regression relative to Swift 3.1.