Question

Within my application I have 20 or so ViewControllers and Xibs that the user should be able to access. The problem is after looking at 5 or so of them the application crashes due to lack of memory. I have released all memory that I have allocated within the ViewControllers so I can only assume it's because its holding the memory of so many IBOutlets.

Heres the code I use to insert the views and at the top also how I remove them:

-(void)InsertUpperHall{
    [lowerHall.view removeFromSuperview];

    if(self.upperHall == nil)
    {
        UpperHall *upperController = [[UpperHall alloc] initWithNibName: @"UpperHall" bundle:nil];
        self.upperHall = upperController;
        [upperController release];
    }
    [self.view insertSubview: upperHall.view atIndex:0];
}

Any help would be greatly appreciated

Was it helpful?

Solution

All IBOutlets that are retained properties need to be set to nil in viewDidUnload and dealloc.

I highly recommend:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top