Unloading XIB from memory
So here's my setup:
- The user spins the PickerWheel, chooses which section of the application to navigate to.
- The app loads the UIViewController from the XIB file and pushes it to the navigationController stack
- User can go back at any time and select a different section to navigate to - viewController is (presumably) completely destroyed and reassigned for a new XIB file
Sounds simple, but each of these sections is very resource intensive. I can't seem to find a good way to completely clear the XIBs from memory when they pop up back - I try to just call [releaseController release] and while it works and end up calling the dealloc - (void) method of the UIViewController subclass, some of the content from the XIB file are still in memory (I can see them there in ObjectAllocations and I can see a lot of memory left in ActivityMonitor).
Basically what I'm asking is, is the best way to completely remove the dynamically loaded XIB from memory?
viewController.view = nil;
If view
is nil on a NIB-managed UIViewController then it will automatically reload the NIB on the next request. This is how it works -didReceiveMemoryWarning
.
As I think about it more, it doesn't throw your IBOutlets right away, which probably makes a difference to your case. Therefore, you also need to implement the special memory management for IBOutlets, described in Nib Object Memory Management .
You need to implement -setView:
as described. Please read this entire document carefully. I wrote a summary of the key points in IBOutlets Memory Management .
a source to share