模态视图关闭后释放内存
我正在使用 Instruments 分析一个 iOS 应用程序,当我在应用程序的 UI 中移动时,我发现内存会增加,但内存永远不会减少。我仔细检查了一下,没有内存泄漏。
打开模态视图控制器时问题似乎变得最糟糕,我猜想在关闭它们后它的内存不会被释放。
所以我的问题是,这是 iOS 平台上的正常行为吗?有关如何在视图关闭且不再显示后以编程方式释放视图的所有分配内存的任何线索?
I am profiling an iOS application with Instruments, and I see that memory grows when I move around the UI of my app, but the memory nevers goes down. I double-checked and there are no memory leaks.
The problem seems to go worst when opening modal view controllers, I guess that its memory don't get released after dismiss them.
So my question is, is that a normal behaviour on iOS platform? Any clue on how to programatically release all alloc memory of a view once it's closed and it won't be displayed anymore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将
UIView
作为 iVar (类成员变量),则在 dealloc 函数中释放它。如果您的视图对象是本地的,则在将其添加到超级视图后释放它。
If you have
UIView
as iVar (class member variable) then release it in dealloc function.If your view object is local then release it after you add it to superview.