pushViewController内存分配问题

时间:2010-11-29 08:19:27

标签: iphone iphone-sdk-3.0 ios4 ios-simulator

我构建了一个应用程序,每个标签栏项包含4个或有时5个嵌套导航..我尝试做每一个但是pushViewController导致仪器中的内存分配问题,我不知道我能做什么, 代码是

[self.navigationController pushViewController:table animated:YES];
[table release];
table=nil;

我尝试打印参考计数,我感到震惊

push之前的引用计数= 1 并且在推动= 4之后

WHY ?? 有人可以帮我吗?


我用来启动表的代码是

custemTable *table=[[custemTable alloc] initWithNibName:@"custemTable" bundle:nil ];
 NSString selectedCellText=((custemCell)[tableView cellForRowAtIndexPath:indexPath]).THNameLabel.text;
 cll=(custemCell)[tableView cellForRowAtIndexPath:indexPath];
 cll.backgroundLabel.backgroundColor=[UIColor ];
 [backgroundSelectedCell release];
 backgroundSelectedCell=nil;
 table.showingTill=selectedCellText;
 table.title=@"...";
 selectedCellText=nil;
 [self.navigationController pushViewController:table animated:YES];
 [table release];
 table=nil;

真正的问题是,当应用程序启动内存分配时为1.56 M,当我选择任何单元格时,pushViewController工作内存为2.8 M,当我回来时,内存保持在2.8 M的范围内(有时约为2.7或2.6) )要知道..没有内存泄漏,我解除了我分配或保留或复制的一切,我不知道我能做什么!!!

2 个答案:

答案 0 :(得分:1)

我会说你的内容还有其他内容泄漏了那段记忆。

您可以粘贴更多代码,包括如何实例化* table吗?

此外,您不应该依赖retainCount值来确定对象是否泄漏。系统还将保留所需的对象,并在不再需要时释放它们,并且您的retainCount将始终受其影响。

作为一般规则,如果您分配,保留或复制对象,则您有责任将其释放。其他所有内容都由系统处理,并将使用自动释放池刷新。

答案 1 :(得分:0)

我用来启动表的代码是

custemTable * table = [[custemTable alloc] initWithNibName:@“custemTable”bundle:nil]; NSString selectedCellText =((custemCell)[tableView cellForRowAtIndexPath:indexPath])。THNameLabel.text; cll =(custemCell)[tableView cellForRowAtIndexPath:indexPath]; cll.backgroundLabel.backgroundColor = [UIColor]; [backgroundSelectedCell release]; backgroundSelectedCell =无; table.showingTill = selectedCellText; table.title = @ “......”; selectedCellText =无; [self.navigationController pushViewController:table animated:YES]; [表格发布]; 表=无;

真正的问题是,当应用程序启动内存分配时为1.56 M,当我选择任何单元格时,pushViewController工作内存为2.8 M 当我将记忆保持在2.8 M的范围内时(有时约为2.7或2.6) 要知道..没有内存泄漏,我解除了我分配,保留或复制的一切 我不知道我能做什么!!!

相关问题