iPhone内存分配问题
在我的应用程序中,我有 20 个左右的 ViewController 和 Xib,用户应该能够访问它们。问题是在查看了大约 5 个之后,应用程序由于内存不足而崩溃。我已经释放了在 ViewController 中分配的所有内存,所以我只能假设这是因为它保存了这么多 IBOutlet 的内存。
这是我用来插入视图的代码,以及在顶部我如何删除它们的代码:
-(void)InsertUpperHall{
[lowerHall.view removeFromSuperview];
if(self.upperHall == nil)
{
UpperHall *upperController = [[UpperHall alloc] initWithNibName: @"UpperHall" bundle:nil];
self.upperHall = upperController;
[upperController release];
}
[self.view insertSubview: upperHall.view atIndex:0];
}
任何帮助将不胜感激
Within my application I have 20 or so ViewControllers and Xibs that the user should be able to access. The problem is after looking at 5 or so of them the application crashes due to lack of memory. I have released all memory that I have allocated within the ViewControllers so I can only assume it's because its holding the memory of so many IBOutlets.
Heres the code I use to insert the views and at the top also how I remove them:
-(void)InsertUpperHall{
[lowerHall.view removeFromSuperview];
if(self.upperHall == nil)
{
UpperHall *upperController = [[UpperHall alloc] initWithNibName: @"UpperHall" bundle:nil];
self.upperHall = upperController;
[upperController release];
}
[self.view insertSubview: upperHall.view atIndex:0];
}
Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有保留属性的 IBOutlet 都需要在 viewDidUnload 和 dealloc 中设置为 nil。
我强烈建议:
All IBOutlets that are retained properties need to be set to nil in viewDidUnload and dealloc.
I highly recommend: