简体   繁体   中英

iPhone: Modal View Controller Leaking Memory

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.

当您呈现模态视图控制器时,您肯定会进行分配,因此在分配时有规则,您也需要释放它,因此请释放您在modalviewcontroller中呈现的视图控制器。

当您呈现模态视图控制器时,您需要释放它。

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM