iPhone应用程序内存从核心框架泄漏

时间:2010-06-16 00:01:54

标签: iphone memory uikit memory-leaks

这些泄漏是否正常?他们是虚假泄漏还是我应该关注的事情?仪器工具没有从我的应用程序给我任何代码行,似乎Apple的框架正在泄漏?! alt text http://www.freeimagehosting.net/uploads/d50bdb5dec.png

好的,问题只能来自这里:

  • (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

    DetailViewController * detailViewController = [[DetailViewController alloc] initWithNibName:@“ProjectDetailView”bundle:[NSBundle mainBundle]];

    Project * project = [projectsArray objectAtIndex:indexPath.row];

    [detailViewController setProject:project];

    [detailViewController setTitle:[project name]];

    [self.navigationController pushViewController:detailViewController animated:YES];

    [detailViewController release];

}

来自详细视图的viewWillAppear事件:

  • (void)viewWillAppear:(BOOL)动画{

    [super viewWillAppear:animated];

    [projectName setText:[project name]];

    [appDefStatement setText:[project appDefStatement]];

    [projectDesc setText:[project desc]];

    NSMutableArray * theSketches = [[NSMutableArray alloc] initWithArray:[project.sketches allObjects]];

    [self setSketchesArray:theSketches];

    [theSketches release];

    if([sketchesArray count] == 0){

    [tView setHidden:YES];  
    

    }其他{

    [tView setHidden:NO];
    

    }

}

3 个答案:

答案 0 :(得分:1)

很少有泄漏来自Apple的源代码的情况,所以我先说第一件事:

  1. 只要您使用alloc,就需要在稍后的安全时间发布您创建的任何对象
  2. 确保.all文件中合成的所有对象都在dealloc调用中释放
  3. 阅读这篇有用的(尽管很无聊)有关内存管理的文章:http://developer.apple.com/iphone/library/documentation/cocoa/conceptual/memorymgmt/memorymgmt.html
  4. 在Leaks http://www.mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/
  5. 上浏览这个很棒的例子

    P.S。如果不发布您的代码,我们只能推测......您可以通过发布可疑代码获得更好的答案。

答案 1 :(得分:0)

尽管苹果公司代码有可能泄漏,但是你看到泄漏的事实并不意味着实际存在泄漏。例如,可能是您从apple的框架中分配了一些内容然后您没有正确发布。

希望这有帮助。

问候

答案 2 :(得分:0)

我认为这些都是虚假泄漏。其中一个漏洞甚至出现了从Apple的文档中获取的一行代码(来自cellForRowAtIndexPath的行试图获取可重用的单元格)。所以我的猜测是泄漏仪器并不完美。我已经多次检查了我的代码,并确保我发布了已分配/复制/保留/ mutableCopied等所有内容。