zoukankan      html  css  js  c++  java
  • 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];

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

  • 相关阅读:
    SQL 大数据查询如何进行优化?
    事件和委托的区别
    虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别
    高并发的秒杀
    C#算法
    口试C#概念
    口试Linq题
    口试大数据及大并发问题
    Windows下MongoDB安装
    MongoDB简单介绍
  • 原文地址:https://www.cnblogs.com/ygm900/p/2891852.html
Copyright © 2011-2022 走看看