Search code examples
iphonememory-managementrootview

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. 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;
}

Solution

  • 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. 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. I dont know if this is the case with you but if you have used multi threading please check if its the case.