【问题标题】:instruments xcode4 not working?仪器 xcode4 不工作?
【发布时间】:2011-11-24 23:00:40
【问题描述】:

我关注 Ray Wenderlich tutorial for instruments,但我不知道为什么分析没有显示泄漏的对象??

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString * sushiName = [_sushiTypes objectAtIndex:indexPath.row];
NSString * sushiString = [NSString stringWithFormat:@"%d: %@", indexPath.row, sushiName];

NSString * message = [NSString stringWithFormat:@"Last sushi: %@.  Cur sushi: %@", _lastSushiSelected, sushiString];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sushi Power!" 
                                                    message:message 
                                                   delegate:nil 
                                          cancelButtonTitle:nil 
                                          otherButtonTitles:@"OK", nil];
[alertView show];

//_lastSushiSelected = sushiString; //el que jode, pues lo pone en string deallocada, por strinWithFormat que usa autorelease!
_lastSushiSelected = [sushiString retain];

//[alertView release];
}

我正在使用教程中的代码,你可以看到 alertView 正在泄漏!

但我通过仪器泄漏运行它,但什么也没有出现! [确认按下停止按钮以停止分析也非常非常慢!]

那么缺少什么??,

非常感谢!

【问题讨论】:

    标签: ios memory-leaks xcode4 instruments


    【解决方案1】:

    坦率地说,我认为这是一个错误。希望它会很快得到修复(我使用的是 v4.1),但一切都没有丢失。在分配工具下,您可以过滤显示哪些类型。在这张图片中,我告诉它显示 UIAlertView 实例。在 UITableView 中单击几次后,您可以看到它告诉我有 2 个实例存在,这确认存在泄漏。

    【讨论】:

    • 我在 xcode 4.2 中的工具中有一些错误。我得到的一个好处是程序变得没有响应并继续运行;我最终使用了强制退出。
    • 是的,我也在 4.1 中看到过。
    • 和 Xcode 3.x 以及......我现在已经养成了创建类静态来计算 totalNumberAllocated 和剩余实例的习惯,以及一个在 dealloc 方法中记录(或不记录)的宏,作为调试级别的函数,我设置为编译开关。跟踪这些的速度要快得多。
    猜你喜欢
    • 1970-01-01
    • 2011-11-15
    • 2014-06-15
    • 2011-08-10
    • 1970-01-01
    • 2018-09-19
    • 2023-03-12
    • 2017-01-12
    • 2018-04-04
    相关资源
    最近更新 更多