The clarification question is as follows:
What exactly should I do in viewDidUnload? When should I free objects - (void) viewDidUnload and not in -dealloc
So, let's say there is a small memory error, and the view is hidden, and viewDidUnload is called. We do a release and dance zero. Later, the entire view stack is not needed, so dealloc is called. Since I already have a release and zero in viewDidUnload, I don't have it in dealloc. Perfect.
But if there is no low memory error, viewDidUnload is never called. dealloc is called, and since I have no release and zero stuff, there is a memory leak.
In other words, will a call to dealloc ever be called without calling viewDidUnload?
and the practical follow up is that if I Alloc and set something in viewDidLoad, and I let it go and set it to zero in viewDidUnload, I leave it from dealloc, or I do a defensive check zero in dealloc and release / zero if it not zero?
memory-management objective-c iphone
alyssackwan
source share