Alert View remaining in memory after closed

Discussion in 'iPhone/iPad Programming' started by 99miles, Apr 30, 2009.

  1. macrumors member

    Joined:
    Oct 10, 2008
    #1
    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?

    Code:
    // 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