Object sent - autorelease too many times, getting

2019-07-29 22:12发布

I am getting too many Object sent - autorelease too many times, this memory leak for my iPhone app and dont know how to resolve it http://screencast.com/t/fPzMNewvq Above is screen shot for the same.

SAAdvertiseCell has lot of objects which are releasing, so how is it possible to find where the exact problem is? Thanks

2条回答
不美不萌又怎样
2楼-- · 2019-07-29 22:50

For creation of Custom UITableViewCell, write your code in this manner:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
      static NSString *CellIdentifier = @"MyTableViewCellId";
      MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

      if (cell == nil) {
          NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MyTableViewCell" owner:self options:nil];
         cell = [topLevelObjects objectAtIndex:0];    
      }

      // write your code to customize cell or providing data content

      return cell;
}

Hope this will help you to solve your problem

查看更多
我只想做你的唯一
3楼-- · 2019-07-29 23:02

At first why don't you reuse cells?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    Cell* cell = [tableView dequeueReusableCellWithIdentifier:cell_id];
    if(!cell)
    {
        cell = // create new cell;
    }

    // configure cell

    return cell;
}

And for your problem: seems that initWithData: already returns an autoreleased object, then you send another autorelease. So check that method to find the problem.

查看更多
登录 后发表回答