开发者

Is this a possible memory leak?

开发者 https://www.devze.com 2023-02-28 06:10 出处:网络
-(IBAction) btnLoginPressed{ Login *loginOver开发者_开发技巧View = [[Login alloc] initWithNibName:@\"Login\" bundle:nil];
-(IBAction) btnLoginPressed{

    Login *loginOver开发者_开发技巧View = [[Login alloc] initWithNibName:@"Login" bundle:nil];
    [self.navigationController pushViewController:loginOverView animated:YES];
    [loginOverView release];
}

loginOverView will never get released?


Why do you think it will never get released?

You have done the right thing by balancing the init with a release.

(in the second line the navigationController does retain login but it will release it itself when it is necessary)


You have released the object which you have taken ownership of through alloc or new. So according to the Memory Management guidelines you must release it. So you have done the right thing.

0

精彩评论

暂无评论...
验证码 换一张
取 消