开发者

iPhone: Modal View Controller Leaking Memory

开发者 https://www.devze.com 2022-12-28 06:42 出处:网络
I\'m presenting a modalViewController. After I dismiss the modal 开发者_如何学编程view controller with:

I'm presenting a modalViewController. After I dismiss the modal 开发者_如何学编程view controller with:

- (void)dismissModalViewControllerAnimated:(BOOL)animated

.. the view is still in memory. How do I dismiss it such that it will use memory?

Thanks.


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


I'm having the same problem. I'm only temporarily retaining the ViewController until I call presentModalViewController, then release the alloc. But after dismissModalViewControllerAnimated, I never get the ViewController's dealloc.

If I add a self-release from the ViewController, then I get this after control returns to the event loop:

Program received signal: “EXC_BAD_ACCESS”. objc_msgSend


Having the same problem. I have a NavigationController that I present modally, and as rootController of this NavigationController I have simple ViewController object. The rare situation is, when I run my app against Instruments using Allocations and after dismissing the modalController, in this case the NavigationController, the NavigationController goes away but the rootController remains in memory and memory grows and grows. (note: Leak in Instruments does not show any leak and the app was running on the device not the simulator).


when you are presenting a modal view controller you will be definitely allocating so there is rule whenever you allocate you need to release it also so please release the view controller which you are presenting in the modalviewcontroller.

0

精彩评论

暂无评论...
验证码 换一张
取 消