Chrysotribax
Chrysotribax

Reputation: 839

iOS4 (UIAlertView) why this code causes memory leaks?

suppose you create a new iOS app from scratch, with just one single window. then you put this code in the appDelegate application didFinishLaunching method :

UIAlertView *myAlert = [[UIAlertView alloc] 
  initWithTitle:@"alert"                                   
  message:@"message"
  delegate:nil /* same problem with 'delegate:self' */
  cancelButtonTitle:nil 
  otherButtonTitles:@"Ok", nil];
[myAlert show];
[myAlert release];

build and run in simulator 4.1, attach instrument, and... this causes each time a memory leak. in simulator 3.1.2 on leopard, no problem at all.

Of course, in a real app, the UIalertView is trigerred by a button, but the result is identical.

What is the problem ? is UIAlertView buggy until iOS4 ?

Upvotes: 1

Views: 918

Answers (1)

deanWombourne
deanWombourne

Reputation: 38485

Don't check for leaks in a simulator. It doesn't have the same memory model so reports leaks when there aren't any.

Test on a real device and if the leak is still there, report it as a bug to Apple :)

Upvotes: 4

Related Questions