iPhone - when is dealloc for a viewcontroller called?
<p>I am using UINavigationController to move between views. When I move back and forth in views, the memory used by my app keeps on increasing. On placing NSLog statements in the dealloc method of all viewcontrollers, I noticed it was being called for only some viewcontrollers and not all that were popped.</p>

<p>For instance, this is the sequence in which views are pushed MainViewController -> viewcontroller1 -> viewcontroller2 -> viewcontroller3</p>

<p>Now in viewcontroller3 if I do a popToViewController:mainController, dealloc is called only for viewcontroller3. It is not called for viewcontroller1 and 2.</p>

<p>Can someone please tell me why this is happening.</p>

<p><strong>Found the problem. The dealloc method was not being called if any of the references held by a viewcontroller were still in memory. In my case it was the MPMoviePlayerController object which was not released in viewcontroller1 and viewcontroller2.</strong></p>
