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-7777] Memory leak when storing closure with optional numeric type #50316
Comments
Sorry, can you share more information about what the leak is? |
Comment by Damian Dudycz (JIRA) Profiler shows Malloc 16 bytes and 32 bytes with responsible library libswiftCore.dylib. One shows responsible frame: swift_unknownUnownedInit, second is: swift_slowAlloc. In memory graph I see leaked "Swift closure context". Screenshots are here: https://i.stack.imgur.com/TG8tT.png https://i.stack.imgur.com/03n1E.png . All you need to reproduce this error is create new single view application for iOS and paste code to AppDelegate. After running there is a leak. This happens in device - I tested on iPhone 6s, haven't seen this in simulator. |
Thanks! I thought you were talking about the AppDelegate being leaked at first, which confused me. The note about device-only is super useful too. @swift-ci create |
(It's possible this is already fixed in the 4.2 development snapshots too.) |
I could not reproduce the leak. Can you attach the whole project? |
Comment by Damian Dudycz (JIRA) Sure. Here is the project - https://www.dropbox.com/s/745j5hclhtncj22/Test.zip?dl=1 |
Comment by Damian Dudycz (JIRA) Just to confirm, this is fixed in Swift 4.2. Thanks |
great, thanks for checking! |
Attachment: Download
Environment
iOS 11.3, Xcode 9.3.1 (9E501), Swift 4.1
Additional Detail from JIRA
md5: f41a6aba51fd2884fae483d23fedf5d2
Issue Description:
If you create an array of closures that have optional numeric type in parameters (eq. Double?), then adding new closures to this array causes a leak. Only if you also capture self in this closure. Very simple example below:
The text was updated successfully, but these errors were encountered: