iPhone - UIViewController 类 dealloc 函数从未被调用
我的一个项目有一个问题。
我有一个“Menu”UIViewController 类,并且从未调用 dealloc 函数。 大部分 UI 是在 Interface Builder 中添加的,没有 IBOutlet。
如果不调用dealloc,如何释放内存?
我模拟了内存警告,现在调用了 dealloc 函数。
这是我的代码示例:
//first.m
- (void) onButton
{ second *modalView = [[second alloc] init];
[self presentModalViewController:modalView animated:YES];
[modalView release];}
那么,当我在第二个屏幕中并模拟内存警告时,第一类的dealloc 是否应该触发?
无论如何,在我的应用程序中没有调用 dealloc :(。
I have an issue with a project of mine.
I have a "Menu" UIViewController class and the dealloc function is never called.
Most of the UI was added in Interface Builder and has no IBOutlet.
How can I free the memory if dealloc is not called?
I simulated an memory warning and now dealloc function was called.
Here is an example of my code:
//first.m
- (void) onButton
{ second *modalView = [[second alloc] init];
[self presentModalViewController:modalView animated:YES];
[modalView release];}
So, when I am in second screen and I simulate memory warning should the dealloc from the first class fire?
Anyway, in my application no dealloc is called :(.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试“硬件->”模拟器中的“模拟内存警告”选项可检查是否调用了 -dealloc。
You can try 'Hardware -> Simulate Memory Warning' option in the Simulator to check whether the -dealloc is called.
Interface Builder 会缓存 nib,直到出现内存警告或耗尽缓存为止。此时,它将回收它正在使用的所有内存。
Interface Builder caches nibs until there's a memory warning, or it exhausts its cache. At such time, it will reclaim any memory that it was using.