仅在设备上的仪器中存在很多奇怪的泄漏(模拟器中没有泄漏) [英] Lot of strange leaks in instruments only on device (no leaks in simulator)

查看:83
本文介绍了仅在设备上的仪器中存在很多奇怪的泄漏(模拟器中没有泄漏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用仪器,并且泄漏很多.我不知道如何解决它们.

I started working with instruments and have a lot of leaks. I don't have an idea how to solve them.

仪器显示我在此行中泄漏:

Instrument show that i have leak in this line:

NSArray *topLevelObjects = [[NSArray alloc] initWithArray:[[NSBundle mainBundle] loadNibNamed:@"SearchResultsTableViewCell" owner:self options:nil]];

这有什么问题?

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"SearchResultsTableViewCell";

 SearchResultsTableViewCell *cell = (SearchResultsTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

 if (cell == nil) {
  NSArray *topLevelObjects = [[NSArray alloc] initWithArray:[[NSBundle mainBundle]
         loadNibNamed:@"SearchResultsTableViewCell"
         owner:self options:nil]];

  for (id currentObject in topLevelObjects) {
   if ([currentObject isKindOfClass:[UITableViewCell class]]) {
    cell = (SearchResultsTableViewCell *) currentObject;
    break;
   }
  }
  [topLevelObjects release], topLevelObjects = nil     ;
 }

    Product *product = [productMutableArray objectAtIndex:indexPath.row];

 cell.textLabel.text = product.title;
 cell.detailTextLabel.text = product.desc1;
 UIImageView *imageView = nil;
 if (product.photo == nil) {
  imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ph38x38.jpg"]];
 } else {
  imageView = [[UIImageView alloc] initWithImage:product.photo];
 }
 imageView.frame = CGRectMake(10., 3., 38., 38.);
 [cell addSubview:imageView];
 [imageView release];

    return cell;
}

我也有很多其他泄漏,但是仪器甚至没有在代码中显示行,例如,存在泄漏: GenerlaBlock-64-UIKit-GetContextStack 我该如何解决?我应该在哪里寻找?

I also have a lot of other leaks, but instruments doesn't even show line in the code, for example there is a leak: GenerlaBlock-64 - UIKit - GetContextStack How can I solve it? where should i look for it?

我在寻找某种类型的教程,但是它们都只显示了带有保留计数,分配和释放的普通示例

I looked for some kind of tutorials, but all of them show only trival examples with retain count, alloc, release

推荐答案

线程正在引起所有问题.我一直在做分叉,而没有返回主线程.那就是问题所在.

Threads were making all the problems. I was doing forks all the time without returning to main thread. That was the problem.

这篇关于仅在设备上的仪器中存在很多奇怪的泄漏(模拟器中没有泄漏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆