简体   繁体   English

回到iPhone中的rootviewcontroller时不会释放内存

[英]Memory is not released when moving back to rootviewcontroller in iPhone

My application starts in a certain view and from there the user can push through several views. 我的应用程序从某个视图开始,用户可以从那里浏览几个视图。 When the user reaches the last view I have provided a button to pop to the rootview controller.But the memory which has been increasing through out the application when each view is pushed, is found to be unreleased. 当用户到达最后一个视图时,我提供了一个弹出到rootview控制器的按钮,但是当每个视图被按下时,在整个应用程序中增加的内存却未被释放。 And again if the user starts using the application it keeps increasing. 同样,如果用户开始使用该应用程序,那么它会不断增加。 I dunno where the problem actually lies. 我不知道问题出在哪里。 Can somebody please help me out of this ?? 有人可以帮我吗?

-(void)buttonPressedStart{
    QuizicleViewController *dvController = [[QuizicleViewController alloc] init];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Cancel" style: UIBarButtonItemStyleBordered target: nil action:nil];
    [[self navigationItem] setBackBarButtonItem: backButton];
    [backButton release];
    [self.navigationController pushViewController:dvController animated:YES];
    [dvController release];
    dvController = nil;
}

Due to my less reputation i have to add an answer. 由于我的声誉欠佳,我必须添加一个答案。 The same thing happened to me a little while ago. 不久前我也发生了同样的事情。 I was pushing a view controller and then releasing it but the dealloc method was not called. 我正在推一个视图控制器,然后释放它,但未调用dealloc方法。 Then after a little debugging i realized that i was doing some work on a separate thread and i was releasing the view without the thread getting complete. 然后,在进行一些调试之后,我意识到我正在一个单独的线程上做一些工作,并且在线程未完成的情况下释放了视图。 As the thread was still running the dealloc method will not be called. 由于线程仍在运行,因此不会调用dealloc方法。 I dont know if this is the case with you but if you have used multi threading please check if its the case. 我不知道这是否适合您,但是如果您使用了多线程,请检查是否适用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM