释放静态分配的 nsarray
我的班级有一个静态数组。我什么时候释放它?或者我不必担心? 我正在考虑用 dealloc 方法释放它,但不确定。 谢谢
I have a static array in my class. When do i release it? or I don't have to worry about it?
I was thinking about releasing it in dealloc method but not sure.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它是静态的,则不应释放它。
If it's static, you shouldn't release it.
如果您担心数组占用的内存量(因为它可能很大,并且您可以根据需要随时重新创建),您可以在收到 didReceiveMemoryWarning 通知后清空该数组。否则真的没有理由太在意它。
If you are concerned about the amount of memory the array takes up (because it's potentially large and is something that you can always recreate if needed), you can empty the array upon receiving a didReceiveMemoryWarning notification. Otherwise there's really no reason to care too much about it.