简体   繁体   English

iPhone:模式视图控制器泄漏的内存

[英]iPhone: Modal View Controller Leaking Memory

I'm presenting a modalViewController. 我正在介绍一个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. 我只是暂时保留ViewController,直到调用presentModalViewController,然后释放alloc。 But after dismissModalViewControllerAnimated, I never get the ViewController's dealloc. 但是在dismissModalViewControllerAnimated之后,我再也没有得到ViewController的解除分配。

If I add a self-release from the ViewController, then I get this after control returns to the event loop: 如果我从ViewController添加了自我发布,那么我将在控件返回事件循环后得到此信息:

Program received signal: “EXC_BAD_ACCESS”. 程序接收信号:“ EXC_BAD_ACCESS”。 objc_msgSend objc_msg发送

Having the same problem. 有同样的问题。 I have a NavigationController that I present modally, and as rootController of this NavigationController I have simple ViewController object. 我有一个模态呈现的NavigationController,作为这个NavigationController的rootController,我有一个简单的ViewController对象。 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. 罕见的情况是,当我使用“分配”在Instruments上运行我的应用程序并关闭了modalController后,在这种情况下,即NavigationController,NavigationController消失了,但rootController仍然保留在内存中,并且内存不断增长。 (note: Leak in Instruments does not show any leak and the app was running on the device not the simulator). (注意:仪器泄漏不会显示任何泄漏,并且应用程序正在设备而非模拟器上运行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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