Alert View remaining in memory after closed

Discussion in 'iOS Programming' started by 99miles, Apr 30, 2009.

  1. 99miles macrumors member

    Oct 10, 2008
    I pop up and alert which takes 180k of memory. When it's dismissed I'd expect that memory to be released but it remains allocated in ObjectAlloc even when I've done all i can to release it. I even added NSAutorelease pools around everything and it makes no difference. Anyone know why this is?

    // create a button than when clicked launches an alert...
    -(void)addNewGameBtn {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    	launchAlertBtn			= [UIButton buttonWithType:UIButtonTypeRoundedRect];
    	[launchAlertBtn setFrame:CGRectMake(20, 250, 280, 30)];
    	[launchAlertBtn setTitle:@"Launch Alert" forState:UIControlStateNormal];
    	launchAlertBtn.userInteractionEnabled = YES;
    	[self.view addSubview:launchAlertBtn];
    	[pool release];
    // pop the alert...
    -(void)onLaunchAlertBtnClick:(id)sender {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New Game" message:@"Start new game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Yes", nil];
    	alert.delegate = self;
    	[alert show];
    	[alert release];
    	[pool release];
    // and for this test I don't do anything the the alert is dismissed

Share This Page