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];

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

  • 相关阅读:
    WLAN 802.11 a/b/g PHY Specification and EDVT Measurement III
    L233
    L232 No methane on Mars
    leetcode 38 Count and Say ---java
    海量字符串查找——bloom filter,c
    leetcode 37 Sudoku Solver java
    mount --bind使用方法
    ECS API
    Linux挂载磁盘
    ECS简述
  • 原文地址:https://www.cnblogs.com/ygm900/p/2891852.html
Copyright © 2011-2022 走看看