Xcode 6.3 (6D543q): [Swift] Memory leak with optional of a protocol type
| Originator: | janoschhildebrand | ||
| Number: | rdar://20256557 | Date Originated: | 23-Mar-2015 |
| Status: | Closed | Resolved: | 8-Jun-2015 |
| Product: | Developer Tools | Product Version: | Xcode 6.3 (6D543q) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: A memory leak occurs with optionals of a protocol type that are backed by a value type larger than ~24 bytes. When a function or property is accessed through optional chaining, the value is copied to a temporary buffer is allocated that is then never freed. The memory is allocated through initializeBufferWithCopyOfBuffer -> swift_slowAlloc -> malloc The Leaks instruments also detects the memory leak and I have attached a Xcode project demonstrating the leak. Steps to Reproduce: 1. Open the attached Xcode project 2. Run it and open the debug navigator in Xcode and keep an eye on memory usage Expected Results: Memory usage should effectively stay constant Actual Results: Memory usage increases steadily Version: Xcode 6.3 (6D543q) Apple Swift version 1.2 (swiftlang-602.0.44.6 clang-602.0.45) OSX 10.10.2 (14C1514)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Example project
https://www.dropbox.com/s/v49nrtb7s8kjsbl/20256557.zip?dl=0