开发者

pushViewController memory allocation problem

I build an application and every tab-bar item contains 4 or sometimes 5 nested navigation..i try to do every thins BUT pushViewController cause a memory allocation problem in instruments and i don't know what can i do,, the code is

开发者_开发问答
[self.navigationController pushViewController:table animated:YES];
[table release];
table=nil;

i try to print the reference count and i was shocked

the reference count before push is = 1 and after push is = 4

WHY?? can anyone help me please??


the code was i used to initiate the table is

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;

the real problem that when the application starts the memory allocation be 1.56 M and when i select any cell and the pushViewController work the memory becaome 2.8 M and when i back the memory stay on range of 2.8 M (about 2.7 or 2.6 sometimes) to know..there are no memory leak and i was relese everything i allocate or retain or copy and i don't what can i do !!!


I would say there is something else in you App leaking that memory.

Can you paste more of your code, including how you are instantiating *table?

Also you shouldn't rely on the retainCount values to determine whether an object is leaking or not. The system will also retain objects that it needs and release it when they are no longer required, and your retainCount will always be affected by that.

As a general rule, if you alloc, retain or copy an object, it is your responsibility to release it. Everything else is dealt with by the system and will be flushed with the auto release pool.


the code was i used to initiate the table is

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;

the real problem that when the application starts the memory allocation be 1.56 M and when i select any cell and the pushViewController work the memory becaome 2.8 M and when i back the memory stay on range of 2.8 M (about 2.7 or 2.6 sometimes) to know..there are no memory leak and i was relese everything i allocate or retain or copy and i don't what can i do !!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜