[英]Memory not released when popViewController Called
Below is the code in which i have some doubts:- 以下是我有疑问的代码:
MyController *vc= [MyViewController alloc] initWithNibName:@"myController"
bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
Then, i pop my controller by pressing the back button on nav bar. 然后,我按导航栏上的后退按钮弹出控制器。
The problem is memory is increased by 5mb(On Activity Monitor) for the first time.And when i pop the controller it doesnt get released. 问题是内存第一次增加了5mb(在Activity Monitor上)。当我弹出控制器时,它没有被释放。 And when i do the push and pop again and again the memory increases by small amount and decreased too.
当我做一次推和一次又一次弹出时,内存会少量增加而减少。
UIView *myView=[UIView alloc]init]; UIView * myView = [UIView alloc] init];
self.vi=myView; self.vi = myView;
[myView release]; [myView版本];
UIScrollView *mySv=[UIScrollView alloc]init]; UIScrollView * mySv = [UIScrollView alloc] init];
self.sv=mySv; self.sv = mySv;
[mySvrelease]; [mySvrelease];
UIProgressView*myPv=[UIProgressViewalloc]init]; UIProgressView * myPv = [UIProgressViewalloc] init];
self.pv=myPv; self.pv = myPv;
[myPvrelease]; [myPvrelease];
UIWebView *myWv=[UIWebView alloc]init]; UIWebView * myWv = [UIWebView alloc] init];
self.wv=myWv; self.wv = myWv;
[myWv release]; [myWv发布];
-(void)dealloc { [wv relase]; -(void)dealloc {[wv relase];
[sv release] [sv版本]
[pv release]; [pv版本];
[vi release]; [vi版本];
[super dealloc]; [super dealloc];
} }
wv,sv,pv,vi are MyViewControoler variables which have retain attribute. wv,sv,pv,vi是具有保留属性的MyViewControoler变量。 I wrote this code to check the memory management concepts,but iam confused now seeing the activity monitor and instruments results.
我编写了这段代码来检查内存管理概念,但是现在看到活动监视器和工具结果使我感到困惑。
I have verified that no object is getting leaked in my MyController class by using Instruments on it. 我已经通过在其MyController类上验证没有对象泄漏到MyController类中。
MyViewController的内容会泄漏
Its not a memory leak. 它不是内存泄漏。 iOS cache the controllers you have visited recently.
iOS会缓存您最近访问过的控制器。 It will get deallocated by iOS itself when your application needs memory to execute some other tasks.
当您的应用程序需要内存来执行其他一些任务时,它将由iOS自身释放。
try this method in MyViewController.m file 在MyViewController.m文件中尝试此方法
- (void)dealloc
{
//release any object thats retained into the memory
[super dealloc];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.