Search code examples
iosmemory-leaksxcode4instruments

instruments xcode4 not working?


Im following Ray Wenderlich tutorial for instruments, but I don't know why the profiling is not showing the leaked object??

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString * sushiName = [_sushiTypes objectAtIndex:indexPath.row];
NSString * sushiString = [NSString stringWithFormat:@"%d: %@", indexPath.row, sushiName];

NSString * message = [NSString stringWithFormat:@"Last sushi: %@.  Cur sushi: %@", _lastSushiSelected, sushiString];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sushi Power!" 
                                                    message:message 
                                                   delegate:nil 
                                          cancelButtonTitle:nil 
                                          otherButtonTitles:@"OK", nil];
[alertView show];

//_lastSushiSelected = sushiString; //el que jode, pues lo pone en string deallocada, por strinWithFormat que usa autorelease!
_lastSushiSelected = [sushiString retain];

//[alertView release];
}

Im using the code in the tutorial, and as you can see the alertView is leaking!

But I run it trough instruments leaks, and nothing appears! [also is very very very slow to acknowledge the stop button was pressed to stop the profiling!]

Leaks not detected

So what is missing??,

thanks a lot!


Solution

  • Frankly, I think it's a bug. Hopefully it'll be fixed soon (I'm using v4.1) but all is not lost. Under the Allocations instrument you can filter which types are displayed. In this image I've told it to show UIAlertView instances. After clicking in the UITableView a couple of times you can see it tells me that there are 2 instances living, which confirms that there is a leak.

    enter image description here