Xcode 7.2: Swift IBOutlet Collection [UIButton]! Leaks Memory
Originator: | joe | ||
Number: | rdar://24272775 | Date Originated: | 21-Jan-2016 12:01 AM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 7.2 (7C68) |
Classification: | Serious Bug | Reproducible: | Always |
Summary: When creating an IBOutlet Collection of UIButtons using Swift, it creates a constant leak in memory. Every access leaks memory I believe due to the forced bridge to ObjectiveC. Steps to Reproduce: 1. Create new single view swift project. 2. Add multiple UIButtons in Interface Builder. 3. Connect them to an IBOutletCollection in the ViewController.swift file. 4. Hit Command+i to run Instruments. 5. Select Leaks as the profiling template. 6. Hit the record button. 7. Leaks! Expected Results: No leaks. Actual Results: Leaks. Notes: Workaround is to replace [UIButton]! with an NSArray! and use your own logic to cast the objects to UIButtons or your subclass.
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!
As a workaround, if you use NSArray! as opposed to [UIButton]!, then this will get rid of the memory leaks.
About this bug
Hi, this bug is still existent in the latest Xcode 7.3 beta and I would like it if it got fixed because we are working on a framework that allows people to make apps very easily and we rely heavily on outlet collections.