IPhone: Modal View Controller Memory Leak

I am introducing modalViewController. After I dismissed the modal view controller with:

- (void)dismissModalViewControllerAnimated:(BOOL)animated

      

.. the view is still in memory. How can I dismiss it so that it uses memory?

Thanks.

+2


a source to share


4 answers


When you present your modal view controller, you need to free it.



0


a source


I have the same problem. I temporarily save the ViewController until I call presentModalViewController and then release alloc. But after dismissing the ModalViewControllerAnimated function, I never get the ViewController dealloc.

If I add self-release from the ViewController, I get this after the control is back in the event loop:



Program signal: "EXC_BAD_ACCESS". objc_msgSend

0


a source


With the same problem. I have a NavigationController that I present modally, and as the rootController of this NavigationController, I have a simple ViewController object. It is rare that I run my application against tools using Allocations and after dismissing modalController, in this case NavigationController, NavigationController goes away but rootController stays in memory and memory grows and grows. (note: "Leak in Tools" does not detect leaks and the app runs on a device, not a simulator).

0


a source


when you present a modal view controller you will definitely highlight so that the rule exists, when you highlight it you need to release it, so release the view controller you present in the modal view controller.

0


a source







All Articles