You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Using interpolated strings in Swift can cause memory leaks to be reported in Instruments. Changing the code from interpolating to concatenating the strings fixes the leak.
I’ve attempted to shrink the repro case down as much as I can, from what I can gather, the problem only occurs when a largish value type is assigned within the same scope. There are other factors involved that I couldn’t discern - making minor changes to the size/structure of the value types can result in the leak disappearing, but the structure I’ve supplied in the sample code will reproduce the issue every time.
Note the types need to be declared in a separate file, and the code compiled -O (fast) with whole module optimisations off.
Description
Summary:
Using interpolated strings in Swift can cause memory leaks to be reported in Instruments. Changing the code from interpolating to concatenating the strings fixes the leak.
I’ve attempted to shrink the repro case down as much as I can, from what I can gather, the problem only occurs when a largish value type is assigned within the same scope. There are other factors involved that I couldn’t discern - making minor changes to the size/structure of the value types can result in the leak disappearing, but the structure I’ve supplied in the sample code will reproduce the issue every time.
Note the types need to be declared in a separate file, and the code compiled -O (fast) with whole module optimisations off.
The relevant code is also available at https://gist.github.com/samritchie/81172456003141415f2fddcd4d3e50e9 if there’s an issue with the zip.
Steps to Reproduce:
Expected Results:
There shouldn’t be any memory leaks, regardless of whether interpolation or concatenation is used
Actual Results:
Instruments detects a memory leak in the interpolation case
Version:
Xcode Version 7.3.1 (7D1014)
OS X 10.11.4 (15E65)
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Notes:
Configuration:
Apple Swift v 2.2 (Xcode 7.3.1). I’ve only tested iOS/iOS Simulator and this specific version of Swift.
Product Version:
Created: 2016-05-19T11:50:04.978650
Originated: 2016-05-19T19:45:00
Open Radar Link: http://www.openradar.me/26366199
The text was updated successfully, but these errors were encountered: