Incorrect decrement of the reference count of an object that is not owned at this point by the caller1

第一种情况

这种问题一般就是变量申请了内存并初始化了,但没有使用此变量,接着将此变量又重新赋值。如下:

NSString *imageString = [[NSString alloc] init];  

imageString = @"HResout";  

 第二种情况

测出的问题提示是 Incorrect decrement of the reference count of an object that is not owned at this point by the caller

问题出现在这一行[self.tableView initWithFrame:self.view.bounds style:UITableViewStyleGrouped];

本人的这个类是继承UITableViewController的,所以它应该会有个成员是tableView的,我想初始化它风格的样式,但是这里出现了这个问题,原因应该是没有创建就初始化了,后来改成这个:

self.tableView =[[[UITableView alloc ]initWithFrame:self.view.boundsstyle:UITableViewStyleGrouped] autorelease]; 

第三种情况

    LoginViewController *loginViewController = [[LoginViewController allocinitwithLoginUrl: loginUrl];

    CustomNavigationController *customNavigationController = [[CustomNavigationController alloc]initWithRootViewController: loginViewController];

    customNavigationController.navigationBar.tintColor = NavgaitonBar_Color;

    [self.navigationController presentModalViewController: customNavigationController animatedYES];

    [loginViewController release];

    [customNavigationController release];

红色为提示内存泄露的地方 

只要把    LoginViewController *loginViewController = [[LoginViewController allocinitwithLoginUrl: loginUrl];

修改为     LoginViewController *loginViewController = [[LoginViewController allocinitWithLoginUrl: loginUrl];

就可以解决内存泄露(就一大小写的差别)

posted @ 2013-02-04 15:19  ygm900  阅读(2725)  评论(0编辑  收藏  举报