Memory leak in UIAlertController
| Originator: | milowulv | ||
| Number: | rdar://20021758 | Date Originated: | 03/03/2015 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | iOS 8.1 |
| Classification: | Reproducible: | Always |
Summary:
Memory leak found by XCode Instrument: Profile->Leaks when presenting UIAlertController.
Sample Code:
{code}
- (IBAction)presentAlertView:(id)sender
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:@"Ohh!" style:UIAlertActionStyleDefault handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Hey" style:UIAlertActionStyleDefault handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
// replyButton should be the reference of the button item which link to this action.
alertController.popoverPresentationController.barButtonItem = self.replyButton;
[self presentViewController:alertController animated:YES completion:NULL];
}
{code}
Steps to Reproduce:
1. Create an navigation bar button item and link the item action to the above code.
2. Use profile -> leaks to lunch the the app.
3. Tap on the bar button and tap a random button in the action sheet and repeat that a couple times.
4. There should be a leak detected in profile-leaks.
Expected Results:
No memory leaks.
Actual Results:
A memory leak detected in profile-leaks.
Regression:
Tested against iPhone 6 Plus, iPhone 6, iPhone 5, iPad Retina simulator,
XCode Version 6.1.1 (6A2008a)
System version: OS X 10.9.5
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!