我应该担心 NIB 文件资源的内存管理吗?
我正在尝试改进 iPhone 应用程序中的内存管理。在 viewDidUnload 中将 IBOutlets 设置为 nil 很有帮助,但我想知道是否需要对笔尖中未连接到任何 IBOutlet 的静态 UIImageView 进行内存管理。或者 iOS 自己能很好地处理它们吗?
I am trying to improve memory management in an iPhone app. It's helped to set IBOutlets to nil in viewDidUnload, but I'm wondering if I need to do any memory management around the static UIImageView's in my nib's which aren't hooked up to any IBOutlet. Or does iOS take care of them well by itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您无需担心在 NIB 中管理任何未附加到插座的资产(包括 UIImageView 资产)。当视图被释放时它们也会被释放。
如果您对应用程序中的内存使用和释放方式有任何疑问,那么最好的选择是使用工具来分析相关视图控制器加载和卸载时的内存消耗情况。当 VC 加载时,您应该会看到内存增加,而当 VC 释放时,内存会回落到之前的水平。如果您多次加载/卸载 VC,并且发现内存使用量稳步增加,那么您就需要开始担心了。
Generally you do not need to worry about managing any assets that aren't attached to an outlet -- including UIImageView assets -- in NIBs. They will released when the view is released.
If you have any concerns about how memory is being used and released in your app, your best bet is to use instruments to profile memory consumption when the view controller in question loads and unloads. You should see memory increase when the VC loads and drop back to previous levels when the VC is released. If you load/unload the VC many times and you see a steady increase in memory usage, that is when you need to start worrying.