In my app im calling presentModelViewController to present a new controller. Everytime this action is triggered memory is allocated. But somehow its not releases properly because at some point my app is using too much memory and it craches.
Probably this is because im not releasing the property objects not correctly ( or not at all ) Is the undermentioned the right way? The dealloc is probably, but what about the viewDidUnload?
- (void)viewDidUnload {
[_sushiTypes release];
_sushiTypes = nil;
}
- (void)dealloc {
[_sushiTypes release];
_sushiTypes = nil;
[super dealloc];
}
Don’t forget the call to super in viewDidUnload. You should also access your instance variable through its setter to set it to nil in viewDidUnload. In dealloc, just release the instance variable directly.
I don’t think this is the source of your memory problems though. Does your modal view controller have any other instance variables or IBOutlets?
To help debug further, try using Instruments. From Xcode, go Product > Profile, then choose the Allocations template when Instruments opens. Then open and close your modal view controller multiple times, and inspect your leaks and allocations. If Allocations are growing each time you present/dismiss, then try clicking the ‘Mark Heap’ button before and after each present/dismiss. You can then inspect the objects that are being allocated and not deallocated with each cycle.